Commit Graph

101794 Commits

Author SHA1 Message Date
Stefan Schulze Frielinghaus f687f5f563 S/390: z13: Accept vector alignment hints
Accept vector alignment hints on z13 although they are ignored there.
The advantage is that any binary compiled for architecture level z13 may
run on z14 or later and benefit from vector alignment hints.

gas/ChangeLog:

2020-05-18  Stefan Schulze Frielinghaus  <stefansf@linux.ibm.com>

	* testsuite/gas/s390/zarch-z13.d: Add regexp checks for vector
	load/store instruction variants with alignment hints.
	* testsuite/gas/s390/zarch-z13.s: Emit new vector load/store
	instruction variants with alignment hints.

opcodes/ChangeLog:

2020-05-18  Stefan Schulze Frielinghaus  <stefansf@linux.ibm.com>

	* s390-opc.txt: Relocate vector load/store instructions with
	additional alignment parameter and change architecture level
	constraint from z14 to z13.
2020-05-26 18:15:41 +02:00
H.J. Lu 8bbc5da5ee gas: Silence GCC 10 warning on tc-visium.c
PR gas/26044
	* config/tc-visium.c (md_convert_frag): Replace fragP->fr_literal
	with &fragP->fr_literal[0].
2020-05-26 07:54:05 -07:00
H.J. Lu c4612b92e3 gas: Silence GCC 10 warning tc-vax.c
PR gas/26044
	* config/tc-vax.c (md_estimate_size_before_relax): Replace
	fragP->fr_literal with &fragP->fr_literal[0].
	(md_convert_frag): Likewise.
2020-05-26 07:41:07 -07:00
H.J. Lu 70b1b570bf gas: Silence GCC 10 warning on tc-v850.c
PR gas/26044
	* config/tc-v850.c (md_convert_frag): Replace fragP->fr_literal
	with &fragP->fr_literal[0].
2020-05-26 06:56:18 -07:00
H.J. Lu e67e940f5d gas: Silence GCC 10 warning on tc-crx.c
opcode/crx.h has

typedef enum
  {
    ...
    MAX_REG
  }
reg;

typedef enum
  {
    c0 = MAX_REG,
  }
copreg;

tc-crx.c has

static int
getreg_image (reg r)
{
  ...
 /* Check whether the register is in registers table.  */
  if (r < MAX_REG)
    rreg = &crx_regtab[r];
  /* Check whether the register is in coprocessor registers table.  */
  else if (r < (int) MAX_COPREG)
    rreg = &crx_copregtab[r-MAX_REG];
}

Change getreg_image's argument type to int and replace fragP->fr_literal
with &fragP->fr_literal[0] to silence GCC 10 warning.

	PR gas/26044
	* config/tc-crx.c (getreg_image): Change argument type to int.
	(md_convert_frag): Replace fragP->fr_literal with
	&fragP->fr_literal[0].
2020-05-26 06:53:36 -07:00
Nick Clifton 9e7cb4c359 Extend the error message displayed when a plugin fails to load.
* plugin.c (try_load_plugin): Extend error message when a plugin
	fails to open.
2020-05-26 14:50:02 +01:00
H.J. Lu a05e3e2039 tc-score.c: Replace overlapping sprintf with memmove
Fix GCC 10 warning:

gas/config/tc-score.c:4575:6: error: ‘sprintf’ argument 3 may overlap destination object ‘keep_data’ [-Werror=restrict]
 4575 |      sprintf (append_str, "bne %s", keep_data);
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

	PR gas/26044
	* onfig/tc-score.c (s3_do_macro_bcmp): Replace overlapping
	sprintf with memmove.
2020-05-26 06:12:37 -07:00
Tom de Vries 40d22035a7 [gdb/testsuite] Add test-case gold-gdb-index.exp
There's a PR binutils/15646 - "gold-generated .gdb_index has duplicated
symbols that gdb-generated index doesn't", and gdb contains a workaround,
added in commit 8943b87476 "Work around gold/15646".

Add a test-case testing this workaround.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-05-26  Tom de Vries  <tdevries@suse.de>

	* gdb.base/gold-gdb-index-2.c: New test.
	* gdb.base/gold-gdb-index.c: New test.
	* gdb.base/gold-gdb-index.exp: New file.
	* gdb.base/gold-gdb-index.h: New test.
2020-05-26 11:35:32 +02:00
H.J. Lu c6412eeea9 gas: Silence GCC 10 warning on tc-mcore.c
* config/tc-mcore.c (md_convert_frag): Replace fragP->fr_literal
	with &fragP->fr_literal[0].
2020-05-25 19:39:13 -07:00
H.J. Lu 9fcc34577e tc-cr16.c: Use memmove to concatenate 2 overlapping strings
PR gas/26041
	* config/tc-cr16.c (md_assemble): Use memmove to concatenate
	2 overlapping strings.
2020-05-25 19:39:13 -07:00
GDB Administrator dcb5d41bef Automatic date update in version.in 2020-05-26 00:00:13 +00:00
H.J. Lu 6c115e16ca gas: Silence GCC 10 warning on tc-cr16.c
* config/tc-cr16.c (md_convert_frag): Replace fragP->fr_literal
	with &fragP->fr_literal[0].
2020-05-25 16:19:49 -07:00
H.J. Lu 68dc60e6a7 ELF: Updated comments for ET_EXEC and ET_DYN
include/elf/common.h has

 #define ET_EXEC         2       /* Executable file */
 #define ET_DYN          3       /* Shared object file */

These predate PIE:

https://groups.google.com/forum/#!topic/generic-abi/mBKlSNldFW4

Updated comments to

 #define ET_EXEC         2       /* Position-dependent executable file */
 #define ET_DYN          3       /* Position-independent executable or
                                    shared object file */

	* elf/common.h: Update comments for ET_EXEC and ET_DYN.
2020-05-25 11:26:48 -07:00
Tom de Vries 043e2e02c0 [gdb/testsuite] Add target board gold-gdb-index
Add new target board that uses gold to add a .gdb_index section, enabled by
-ggnu-pubnames.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-05-25  Tom de Vries  <tdevries@suse.de>

	* boards/gold-gdb-index.exp: New file.
2020-05-25 19:36:05 +02:00
Cristiano De Alti 1218a4bf49 gdb: make avr_integer_to_address generate code or data address based on type
The AVR architecture is a Harvard one, meaning it has different memory
spaces for code and data.  In GDB, this is dealt with by having the data
(SRAM) addresses start at 0x00800000.  When interpreting an integer as
an address (converting to a CORE_ADDR), we currently always generate a
data address.  This doesn't work for some cases described below, where
the integer is meant to represent a code address.

This patch changes avr_integer_to_address so that it generates the
correct type of address (code or data) based on the passed type.

Using the simavr.exp board, I didn't see any regressions when running
the gdb.base/*.exp tests.  A few tests go from fail to pass, but none
from pass to fail.  There are a few new fails and unresolved, but it's
just because some tests manage to make more progress before failing in a
different way.

In practice, it fixes disassembling by address, as described in the PR:

    - (gdb) disassemble 0x12a,0x12b
    - Dump of assembler code from 0x12a to 0x12b:
    -    0x0000012a <main+0>: push    r28
    - End of assembler dump.

    + (gdb) disassemble 0x12a,0x12b
    + Dump of assembler code from 0x80012a to 0x80012b:
    +    0x0080012a:  nop
    + End of assembler dump.

And also, setting a breakpoint by address:

    - (gdb) p &main
    - $1 = (int (*)(void)) 0x12a <main>
    - (gdb) b *0x12a
    - Breakpoint 1 at 0x80012a

    + (gdb) p &main
    + $1 = (int (*)(void)) 0x12a <main>
    + (gdb) b *0x12a
    + Breakpoint 1 at 0x12a: file test-avr.c, line 3.
    + Note: automatically using hardware breakpoints for read-only addresses.

gdb/ChangeLog:

	PR gdb/13519
	* avr-tdep.c (avr_integer_to_address): Return data or code
	address accordingly to the second 'type' argument of the
	function.

Change-Id: Iaea1587d053e86f4ab8aebdcabec8d31a6d262cd
2020-05-25 11:56:14 -04:00
Simon Marchi 462f72c552 gdb/testsuite: add simavr.exp board
This patch adds a board file for against a simavr target (so, for the
AVR architecture).

simavr, when started with option -g, runs a GDB stub on port 1234.  In
the current latest release (1.6), the port is hardcoded to 1234.  But in
master, there is the option to choose another port.  So while the board
file hardcodes the port today, in the future it should be possible to
let the user choose a port, or automatically select a free port.

It is easy enough to run, make sure you have avr-gcc/avr-g++ and simavr
installed, and as usual just run:

    make check RUNTESTFLAGS="--target_board=simavr"

The following environment variables influence the behavior of the board
file:

  - SIMAVR_MCU: type of chip to simulate
  - SIMAVR_PATH: path to simavr binary (useful if you build your own
    simavr or for some reason it is not simply called `simavr`.

As expected, there are a lot of failures.  Many tests use some features
not supported by such a target, and I suppose there are real GDB bugs
too.  But a lot also passes (including tests that actually run stuff),
so this board file should still help to validate changes to the AVR
architecture support.

These are the results I got of running tests gdb.base/*.exp:

    # of expected passes            20926
    # of unexpected failures        2257
    # of expected failures          14
    # of unknown successes          1
    # of known failures             13
    # of unresolved testcases       592
    # of untested testcases         156
    # of unsupported tests          30
    # of paths in test names        3
    # of duplicate test names       56

gdb/testsuite/ChangeLog:

	* boards/simavr.exp: New file.

Change-Id: Ib7fa8c4e2e90b08b104bb9b552df37779de3bc21
2020-05-25 11:55:21 -04:00
Simon Marchi 6cf66e763a gdb/testsuite: add inferior arguments test
Add a test for verifying different methods of passing arguments to the
inferior: the start, starti and run commands, as well as `set args`.

All these methods work naturally when using the unix or
native-extended-gdbserver target boards.  Since those are non-stub
boards, GDB runs new inferiors and therefore pass arguments to them.
With target boards where GDB connects to a stub, for example with
native-gdbserver, they don't really make sense.  The inferior process is
already started when GDB connects.

However, the "run" method is still tested with stub targets, because the
gdb_run_cmd procedure is adapted for stub targets.  Instead of issuing
the `run` command, it spawns whatever program is supposed to bring up
the stub (gdbserver, for example) using gdb_reload and makes GDB connect
to it.  So this allows us to exercise argument passing through the
gdbserver command line, when testing with the native-gdbserver board.

Note that there is already a gdb.base/args.exp, but this tests
specifically the --args switch of GDB.  Perhaps it could be integrated
in this new test, as a new "method".

gdb/testsuite/ChangeLog:

	* lib/gdb.exp (gdb_run_cmd): Return success or failure.
	* gdb.base/inferior-args.exp: New file.
	* gdb.base/inferior-args.c: New file.

Change-Id: Ib61ea6220a47f9f67aed2960dcacd240cb57af70
2020-05-25 11:40:36 -04:00
Simon Marchi 75d0451240 gdb/testsuite: support passing inferior arguments with native-gdbserver board
This patch makes it possible to run tests requiring passing arguments to
the inferior with the native-gdbserver board.  The end goal is to write
a test that verifies passing arguments to the inferior works, and to
have that test exercise inferior arguments passed on the gdbserver
command line, when using the native-gdbserver target board (in addition
to the other boards).  This is done in the next patch.

With the native-gdbserver target board, gdbserver is started in
gdb_reload (implemented in config/gdbserver.exp), called in gdb_run_cmd.
gdb_run_cmd already supposedly accepts inferior arguments (although that
feature does not seem to be used anywhere), which it passes to the `run`
command, for non-stub target boards.  I've changed gdb_run_cmd so that
it forwards these arguments to gdb_reload as well.  gdb_reload passes
them to gdbserver_run, and they eventually make their way to the
gdbserver command line.

gdb_run_cmd currently accepts `args` (the varargs of tcl), which means
it receives inferior arguments as a list.  This won't work with
arguments with spaces, because they will end up being formatted with
curly braces like this:

    % set args [list hello "with spaces" world]
    hello {with spaces} world
    % puts "run $args"
    run hello {with spaces} world

I've changed it to accept a single string that is passed to `run` and
gdb_reload.  I've done the same change in gdb_start_cmd and
gdb_starti_cmd, although these two are not used with native-gdbserver.

I've changed all gdb_reload implementations in the tree to accept a new
inferior_args argument, although most of them don't do anything with it
(and don't need to).  People maintaining target boards out of tree will
need to do the same.

I found two tests to adjust to avoid adding new failures or errors.
These tests needed new [use_gdb_stub] checks, because they rely on
having GDB run new processes.  These are guarded by a [target_info
exists noargs], which made them get skipped on native-gdbserver.  But
now that the native-gdbserver board supports args, this is no longer
enough.

Note that with this change, noargs and use_gdb_stub are orthogonal.  It
took me a moment to grasp this, so I thought I would spell out the
different possible situations:

- !noargs and !use_gdb_stub: inferior process started by gdb, can pass
  args
- noargs and !use_gdb_stub: inferior process started by gdb (perhaps
  through extended-remote protocol, the simulator, some other target),
  but that target doesn't support inferior arguments
- noargs and use_gdb_stub: inferior process started by some other
  program to which GDB connects using the remote protocol, that program
  does not support passing args to the inferior process
- !noargs and use_gdb_stub: inferior process started by some other
  program to which GDB connects u sing the remote protocol, that program
  supports passing args to the inferior process

gdb/testsuite/ChangeLog:

	* lib/gdb.exp (gdb_run_cmd): Change argument from args to
	inferior_args.  Pass it to gdb_reload.
	(gdb_start_cmd, gdb_starti_cmd): Change argument from args to
	inferior_args.
	(gdb_reload): Add inferior_args argument.
	* config/gdbserver.exp (gdb_reload): Add inferior_args argument,
	pass it to gdbserver_run.
	* boards/native-gdbserver.exp: Do not set noargs.
	* boards/native-extended-gdbserver.exp (gdb_reload): Add
	inferior_args argument.
	* boards/stdio-gdbserver-base.exp (gdb_reload): Likewise.
	* gdb.base/a2-run.exp: Check for use_gdb_stub.
	* gdb.base/args.exp: Likewise.

Change-Id: Ibda027c71867157852f34700342ab31edf39e4d8
2020-05-25 11:40:36 -04:00
Michael Weghorn 7dbfcd6f79 gdbsupport: Drop now unused function 'stringify_argv'
The function did not properly escape special characters
and all uses have been replaced in previous commits, so
drop the now unused function.

gdbsupport/ChangeLog:

	* common-utils.cc, common-utils.h (stringify_argv): Drop
	now unused function stringify_argv

Change-Id: Id5f861f44eae1f0fbde3476a5eac23a842ed04fc
2020-05-25 11:40:35 -04:00
Michael Weghorn bea571ebd7 Use construct_inferior_arguments which handles special chars
Use the construct_inferior_arguments function instead of
stringify_argv to construct a string from the program
arguments in those places where that one is then passed
to fork_inferior (linux-low, lyn-low), since
construct_inferior_arguments properly takes care of
special characters, while stringify_argv does not.
Using construct_inferior_arguments seems "natural", since its
documentation also mentions that it "does the
same shell processing as fork_inferior".

Since construct_inferior_args has been extended to do
proper quoting for Windows shells in commit
5d60742e2d
("Fix quoting of special characters for the MinGW build.",
2012-06-12), use it for the Windows case as well.
(I could not test that case myself, though.)

Adapt handling of empty args in function 'handle_v_run'
in gdbserver/server.cc to just insert an empty string
for an empty arg, since that one is now properly handled
in 'construct_inferior_arguments' already (and inserting
a "''" string in 'handle_v_run' would otherwise
cause that one to be treated as a string literally
containing two quote characters, which
'construct_inferior_args' would preserve by adding
extra escaping).

This makes gdbserver properly handle program args containing special
characters (like spaces), e.g. (example from PR25893)

  $ gdbserver localhost:50505 myprogram "hello world"

now properly handles "hello world" as a single arg, not two separate
ones ("hello", "world").

gdbserver/ChangeLog:

	PR gdbserver/25893
	* linux-low.cc (linux_process_target::create_inferior),
	lynx-low.cc (lynx_process_target::create_inferior),
	win32-low.cc (win32_process_target::create_inferior): Use
	construct_inferior_arguments instead of stringify_argv
	to get string representation which properly escapes
	special characters.
	* server.cc (handle_v_run): Just pass empty program arg
	as such, since any further processing is now handled via
	construct_inferior_arguments.

Change-Id: Ibf963fcd51415c948840fb463289516b3479b0c3
2020-05-25 11:40:00 -04:00
Michael Weghorn ace6b9195e nto_process_target::create_inferior: Pass args as char **
According to [1], the fifth parameter
to the 'spawnp' function is 'char * const argv[]',
so just pass the args contained in the vector as
an array right away, rather than converting that
to a C string first and passing that one.

With commit 2090129c36
("Share fork_inferior et al with gdbserver",
2016-12-22) the type had changed from 'char **'
to 'char *', but I can't see an apparent reason for
that, and 'nto_procfs_target::create_inferior'
(in gdb/nto-procfs.c) also passes a 'char **' to
'spawnp' instead.

I do not know much about that target and cannot actually
test this, however.
The main motivation to look at this was identifying
and replacing the remaining uses of the 'stringify_argv'
function which does not properly do escaping.

[1] http://www.qnx.com/developers/docs/7.0.0/#com.qnx.doc.neutrino.lib_ref/topic/s/spawnp.html

gdbserver/ChangeLog:

	* nto-low.cc (nto_process_target::create_inferior): Pass
	argv to spawnp function as char **.

Change-Id: Ic46fe745c2aa1118114240d149d4156032f84344
2020-05-25 11:39:35 -04:00
Michael Weghorn b69ca137ac gdbserver: Don't add extra NULL to program args
The vector holding the program args is passed as a parameter
to target_create_inferior, which then passes it to
stringify_argv for all platforms, where any NULL entry in
the vector is ignored, so there seems to be no reason
to actually add one after all.

(Since the intention is to replace uses of stringify_argv with
construct_inferior_arguments in a follow-up commit and that
function doesn't currently handle such NULL arguments, it
would otherwise have to be extended.)

gdbserver/ChangeLog:

	* server.cc (captured_main), (handle_v_run): No longer
	insert extra NULL element to args vector.

Change-Id: Ia2ef6d36814a6b11ce8b0d6e3b33248a7945e825
2020-05-25 11:39:11 -04:00
Michael Weghorn 8c4b5f3d98 gdbsupport: Let construct_inferior_arguments take gdb::array_view param
Adapt the construct_inferior_arguments function to
take a gdb::array_view<char * const> parameter instead
of a char * array and an int indicating the length
and adapt the only call site.

This will allow calling it more simply in a follow-up
patch introducing more uses of the function.

gdbsupport/ChangeLog:

	* common-inferior.cc, common-inferior.h (construct_inferior_arguments):
	Adapt to take a gdb::array_view<char * const> parameter.
	Adapt call site.

Change-Id: I1c6496c8c0b0eb3ef3fda96e9e3bd64c5e6cac3c
2020-05-25 11:38:45 -04:00
Michael Weghorn c699004a29 gdbsupport: Adapt construct_inferior_arguments
Allow construct_inferior_arguments to handle zero args
and have it return a std::string, similar to how
stringify_argv in gdbsupport/common-utils does.

Also, add a const qualifier for the second parameter,
since it is only read, not written to.

The intention is to replace existing uses of
stringify_argv by construct_inferior_arguments
in a subsequent step, since construct_inferior_arguments
properly handles special characters, while stringify_argv
doesn't.

gdbsupport/ChangeLog:

	* common-inferior.cc, common-inferior.h (construct_inferior_arguments):
	Adapt to handle zero args and return a std::string.
	Adapt call site.

Change-Id: I126c4390a1018c7527b0b8fd545252ab8a5a7adc
2020-05-25 11:38:26 -04:00
Michael Weghorn 92651b1d91 gdb: Move construct_inferior_arguments to gdbsupport
This moves the function construct_inferior_arguments from
gdb/inferior.h and gdb/infcmd.c to gdbsupport/common-inferior.{h,cc}.
While at it, also move the function's comment to the header file
to align with current standards.

The intention is to use it from gdbserver in a follow-up commit.

gdb/ChangeLog:

	* infcmd.c, inferior.h: (construct_inferior_arguments):
	Moved function from here to gdbsupport/common-inferior.{h,cc}

gdbsupport/ChangeLog:

	* common-inferior.h, common-inferior.cc: (construct_inferior_arguments):
	Move function here from gdb/infcmd.c, gdb/inferior.h

Change-Id: Ib9290464ce8c0872f605d8829f88352d064c30d6
2020-05-25 11:38:02 -04:00
Tom de Vries 42cf184456 [gdb/testsuite] Add comment in exec_is_pie
Add comment to exec_is_pie explaining why readelf -d output is not used.

gdb/testsuite/ChangeLog:

2020-05-25  Tom de Vries  <tdevries@suse.de>

	* lib/gdb.exp (exec_is_pie): Add comment.
2020-05-25 17:27:49 +02:00
H.J. Lu 07e0bb0fb2 ld-x86-64: Pass -z notext to linker for tests with DT_TEXTREL
* testsuite/ld-x86-64/x86-64.exp: Pass -z notext to linker.
2020-05-25 06:45:13 -07:00
H.J. Lu af2c48d854 ld: Pass -z notext to linker for tests with DT_TEXTREL
Some linker tests need DT_TEXTREL.  Pass -z notext to linker for these
tests so that they will pass with DT_TEXTREL check defaulting to warning
or error.

	* testsuite/ld-elf/eh6.d: Pass -z notext to linker.
	* testsuite/ld-elf/ehdr_start-shared.d: Likewise.
	* testsuite/ld-elf/pr19539.d: Likewise.
	* testsuite/ld-elfvers/vers.exp: Likewise.
	* testsuite/ld-elfvsb/elfvsb.exp: Likewise.
	* testsuite/ld-i386/i386.exp: Likewise.
	* testsuite/ld-i386/nogot1.d: Likewise.
	* testsuite/ld-i386/pr19539.d: Likewise.
	* testsuite/ld-i386/pr19636-2a.d: Likewise.
	* testsuite/ld-i386/pr19636-2b.d: Likewise.
	* testsuite/ld-i386/pr19636-2c.d: Likewise.
	* testsuite/ld-i386/pr19636-2d.d: Likewise.
	* testsuite/ld-i386/pr19636-2e.d: Likewise.
	* testsuite/ld-i386/pr19636-3d.d: Likewise.
	* testsuite/ld-i386/pr19636-3e.d: Likewise.
	* testsuite/ld-i386/pr19939b.d: Likewise.
	* testsuite/ld-i386/undefweaka.d: Likewise.
	* testsuite/ld-i386/undefweakb.d: Likewise.
	* testsuite/ld-shared/shared.exp: Likewise.
	* testsuite/ld-size/size.exp: Likewise.
	* testsuite/ld-unique/unique.exp: Likewise.
	* testsuite/ld-x86-64/pie1.d: Likewise.
	* testsuite/ld-x86-64/pr19539a.d: Likewise.
	* testsuite/ld-x86-64/pr19539b.d: Likewise.
	* testsuite/ld-x86-64/pr19636-1d.d: Likewise.
	* testsuite/ld-x86-64/pr19636-1e.d: Likewise.
	* testsuite/ld-x86-64/pr19807-1a.d: Likewise.
	* testsuite/ld-x86-64/pr19807-1b.d: Likewise.
	* testsuite/ld-x86-64/pr19807-2b.d: Likewise.
	* testsuite/ld-x86-64/pr19807-2c.d: Likewise.
	* testsuite/ld-x86-64/pr19807-2d.d: Likewise.
	* testsuite/ld-x86-64/pr19807-2e.d: Likewise.
	* testsuite/ld-x86-64/pr19939b.d: Likewise.
	* testsuite/ld-x86-64/x86-64.exp: Likewise.
2020-05-25 04:54:50 -07:00
H.J. Lu a39d29cda1 gas: Update fr_literal access in frag for GCC 10
When access fr_literal in

struct frag {
  ...
  /* Data begins here.  */
  char fr_literal[1];
};

with

char *buf = fragp->fr_fix + fragp->fr_literal;

GCC 10 gave

gas/config/tc-csky.c: In function ‘md_convert_frag’:
gas/config/tc-csky.c:4507:9: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
 4507 |  buf[1] = BYTE_1 (CSKYV1_INST_SUBI | (7 << 4));
      |         ^

Change

  char *buf = fragp->fr_fix + fragp->fr_literal;

to

  char *buf = fragp->fr_fix + &fragp->fr_literal[0];

to silence GCC 10 warning.

	* config/tc-csky.c (md_convert_frag): Replace fragp->fr_literal
	with &fragp->fr_literal[0].
	* config/tc-microblaze.c (md_apply_fix): Likewise.
	* config/tc-sh.c (md_convert_frag): Likewise.
2020-05-25 04:51:17 -07:00
Tom de Vries 8f7d38efad [gdb/testsuite] Fix var use in compile_and_download_n_jit_so
In commit 1b59ca1cf1 "[gdb/testsuite] Fix tcl error in jit-elf-helpers.exp", I
introduced a variable f in compile_and_download_n_jit_so, to be used in the
untested message, but actually variable binfile was used instead:
...
+           set f [file tail $binfile]
+           untested "failed to compile shared library $binfile"
...

Fix this by using $f in the untested message.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-05-25  Tom de Vries  <tdevries@suse.de>

	* lib/jit-elf-helpers.exp (compile_and_download_n_jit_so): Use $f
	instead of $binfile in the untested message.
2020-05-25 12:28:54 +02:00
Tom de Vries 465e1b0f19 [gdb/testsuite] Fix exec_is_pie with gold linker
When running test-case gdb.base/break-interp.exp with target board gold, we
run into:
...
gdb compile failed, pie failed to generate PIE executable
...

The problem is that the proc exec_is_pie uses the PIE flag in the readelf -d
output, which doesn't seem to be set by the gold linker.

Instead, use the "Type" field in the readelf -h output.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-05-25  Tom de Vries  <tdevries@suse.de>

	PR testsuite/26031
	* lib/gdb.exp (exec_is_pie): Test readelf -h output.
2020-05-25 12:01:52 +02:00
Tom de Vries 3c5a0e025b [gdb/testsuite] Add target board gold
Add a target board that uses the gold linker.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-05-25  Tom de Vries  <tdevries@suse.de>

	* boards/gold.exp: New file.
2020-05-25 12:01:52 +02:00
Tom Tromey 0a4f5f8cae Revert "Add completion styling"
This reverts commit eca1f90cf4.  Several
changes were requested, and it seemed simplest to revert it.

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

	Revert commit eca1f90c:
	* NEWS: Remove entry for completion styling.
	* completer.c (_rl_completion_prefix_display_length): Move
	declaration later.
	(gdb_fnprint): Revert.
	(gdb_display_match_list_1): Likewise.
	* cli/cli-style.c (completion_prefix_style)
	(completion_difference_style, completion_suffix_style): Remove.
	(_initialize_cli_style): Revert.
	* cli/cli-style.h (completion_prefix_style)
	(completion_difference_style, completion_suffix_style): Don't
	declare.

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

	* gdb.texinfo (Output Styling): Don't mention completion styling.
	(Editing): Don't mention readline completion styling.

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

	* gdb.base/style.exp: Remove completion styling test.
	* lib/gdb-utils.exp (style): Remove completion styles.
2020-05-24 20:27:48 -06:00
GDB Administrator ddb9ebd500 Automatic date update in version.in 2020-05-25 00:00:06 +00:00
Jim Wilson 72393fd103 RISC-V: Gas inserts cfa relocs in wrong section.
The frag code makes a distinction between inserting frags before the frag
chains are chained together and afterward.  After chaining, we need to set
now_seg before creating the frag.  tc-xtensa.c has a function called
fix_new_exp_in_seg that handles this right, but switches segments twice each
time it is called.  In this case, we can inline it and pull the save and
restore out of the loop to get better code.

	gas/
	PR 26025
	* config/tc-riscv.c (riscv_pre_output_hook): Change s type from const
	asection to segT.  New locals seg and subseg.  Call subseg_set before
	fix_new_exp.  Call subseg_set after loop to restore original values.
2020-05-24 16:42:21 -07:00
Simon Marchi 41a77cbaad gdb: make gdbarch.sh write gdbarch.{c,h} directly
It was suggested in this thread [1] that gdbarch.sh should write to
gdbarch.h and gdbarch.c directly.  This patch implements that.

When running gdbarch.sh, we currently need to move new-gdbarch.c over
gdbarch.c and new-gdbarch.h over gdbarch.h.  It might have been useful
at some point to not have gdbarch.sh overwrite gdbarch.h and gdbarch.c,
but with git it's really unnecessary.  Any changes to gdbarch.sh can be
inspected using `git diff`.

A next step would be to have the Makefile automatically run gdbarch.sh
if it sees that gdbarch.c and gdbarch.h are out of date.  Or maybe even
remove gdbarch.c and gdbarch.h from the tree and generate them in the
build directory when building.  But that requires more thinking and
discussions, and I think that this change is already useful in itself.

[1] https://sourceware.org/pipermail/gdb-patches/2020-May/168265.html

gdb/ChangeLog;

	* gdbarch.sh: Write to gdbarch.c/gdbarch.h directly.  Don't
	compare old and new versions.
	(compare_new): Remove.

Change-Id: I7970a9e8af0afc0145cb5a28e73d94fbaa1e25b9
2020-05-24 11:11:36 -04:00
Pedro Alves e08bd6c508 Don't remove C++ aliases from completions if symbol doesn't match
completion_list_add_symbol currently tries to remove C++ function
aliases from the completions match list even if the symbol passed down
wasn't successfully added to the completion list because it didn't
match.  I.e., we call cp_canonicalize_string_no_typedefs for each and
every C++ function in the program, which is useful work.  This patch
skips that useless work.

gdb/ChangeLog:
2020-05-24  Pedro Alves  <palves@redhat.com>

	* symtab.c (completion_list_add_name): Return boolean indication
	of whether the symbol matched.
	(completion_list_add_symbol): Don't try to remove C++ aliases if
	the symbol didn't match in the first place.
	* symtab.h (completion_list_add_name): Return bool.
2020-05-24 13:32:25 +01:00
Fangrui Song bb68f22c8e ld: Handle --dynamic-list* before -Bsymbolic -Bsymbolic-functions
--dynamic-list* should work both before and after -Bsymbolic and
-Bsymbolic-functions.

	PR ld/26018
	* lexsup.c (parse_args): Simplify.
	* testsuite/ld-elf/dl4e.out: New.
	* testsuite/ld-elf/shared.exp: Updated for PR ld/26018 tests.
2020-05-24 04:47:46 -07:00
H.J. Lu 309cae1f7b ld: Add -Bsymbolic-functions tests
PR ld/26018
	* testsuite/ld-i386/i386.exp: Add a -Bsymbolic-functions test.
	* testsuite/ld-x86-64/x86-64.exp: Likewise.
	* testsuite/ld-i386/pr26018.d: New file.
	* testsuite/ld-x86-64/pr26018.d: Likewise.
	* testsuite/ld-x86-64/pr26018.s: Likewise.
2020-05-23 20:56:31 -07:00
GDB Administrator 4636b7db71 Automatic date update in version.in 2020-05-24 00:00:06 +00:00
Simon Marchi ceacbf6edf gdb: remove TYPE_FIELD macro
Replace all uses of it by type::field.

Note that since type::field returns a reference to the field, some spots
are used to assign the whole field structure.  See ctfread.c, function
attach_fields_to_type, for example.  This is the same as was happening
with the macro, so I don't think it's a problem, but if anybody sees a
really nicer way to do this, now could be a good time to implement it.

gdb/ChangeLog:

	* gdbtypes.h (TYPE_FIELD): Remove.  Replace all uses with
	type::field.
2020-05-23 17:39:54 -04:00
Joel Brobecker 26f1625454 Document the GDB 9.2 release in gdb/ChangeLog
gdb/ChangeLog:

	GDB 9.2 released.
2020-05-23 14:19:06 -07:00
Tom Tromey eca1f90cf4 Add completion styling
Readline has a styling feature for completion -- if it is enabled, the
common prefix of completions will be displayed in a different style.
This doesn't work in gdb, because gdb implements its own completer.

This patch implements the feature.  However, it doesn't directly use
the Readline feature, because gdb can do a bit better: it can let the
user control the styling using the existing mechanisms.

This version incorporates an Emacs idea, via Eli: style the prefix,
the "difference character", and the suffix differently.

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

	* NEWS: Add entry for completion styling.
	* completer.c (_rl_completion_prefix_display_length): Move
	declaration earlier.
	(gdb_fnprint): Use completion_style.
	(gdb_display_match_list_1): Likewise.
	* cli/cli-style.c (completion_prefix_style)
	(completion_difference_style, completion_suffix_style): New
	globals.
	(_initialize_cli_style): Register new globals.
	* cli/cli-style.h (completion_prefix_style)
	(completion_difference_style, completion_suffix_style): Declare.

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

	* gdb.texinfo (Output Styling): Mention completion styling.
	(Editing): Mention readline completion styling.

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

	* gdb.base/style.exp: Add completion styling test.
	* lib/gdb-utils.exp (style): Add completion styles.
2020-05-23 14:53:33 -06:00
Pedro Alves 51e2cfa2dc Use safe-ctype.h (ISSPACE etc.) in symbol parsing & comparison
This patch avoids depending on the current locale when parsing &
comparing symbol names, by using libiberty's safe-ctype.h uppercase
TOLOWER, ISXDIGIT, etc. macros instead of the standard ctype.h
tolower, isxdigit, etc. macros/functions.

This commit:

 commit b1b60145ae
 Author:     Pedro Alves <palves@redhat.com>
 AuthorDate: Tue May 22 17:35:38 2018 +0100

    Support UTF-8 identifiers in C/C++ expressions (PR gdb/22973)

did something similar, except in the expression parser.

This can improve GDB's symbol loading performance significantly.
Currently strcmp_iw_ordered can show up high on profiles (called from
sort_pst_symbols -> std::sort) because of the isspace and tolower
functions.  Hannes mentions seeing it as high as in ~24% of the
profiling samples on Windows
(https://sourceware.org/pipermail/gdb-patches/2020-May/168858.html).

I tested GDB's performance (built with "-g -O2") loading a "-g -O0"
build of gdb.

I ran GDB 10 times like:

	  /bin/time -f %e \
		    ./gdb/gdb --data-directory ./gdb/data-directory -nx \
		    -batch /tmp/gdb-g-O0

Then I computed the mean time.

The baseline mean time was

 gdb    2.515

This patch brings the number down to

 gdb    2.096

Which is an around 16% improvement.

gdb/ChangeLog:
2020-05-23  Pedro Alves  <palves@redhat.com>

	* utils.c: Include "gdbsupport/gdb-safe-ctype.h".
	(parse_escape): Use ISDIGIT instead of isdigit.
	(puts_debug): Use gdb_isprint instead of isprint.
	(fprintf_symbol_filtered): Use ISALNUM instead of isalnum.
	(cp_skip_operator_token, skip_ws, strncmp_iw_with_mode): Use
	ISSPACE instead of isspace.
	(strncmp_iw_with_mode): Use TOLOWER instead of tolower and ISSPACE
	instead of isspace.
	(strcmp_iw_ordered): Use ISSPACE instead of isspace.
	(string_to_core_addr): Use TOLOWER instead of tolower, ISXDIGIT
	instead of isxdigit and ISDIGIT instead of isdigit.

gdbsupport/ChangeLog:
2020-05-23  Pedro Alves  <palves@redhat.com>

	* gdb-safe-ctype.h: New.
2020-05-23 12:46:37 +01:00
Alan Modra c892b44730 Fix potential segfault
Code in vms-lib.c leaves arch_header NULL.

	* bfdio.c (bfd_get_file_size): Don't segfault on NULL arch_header.
2020-05-23 16:56:38 +09:30
Alan Modra 3f3c36087e ar many_files test
This tests for the issue fixed with git commit 0490dd41ae.

	* testsuite/binutils-all/ar.exp (many_files): New test.
2020-05-23 14:56:07 +09:30
GDB Administrator a3d674e022 Automatic date update in version.in 2020-05-23 00:00:14 +00:00
Simon Marchi 80fc5e77f0 gdb: remove TYPE_FIELDS macro
Remove all uses of the `TYPE_FIELDS` macro.  Replace them with either:

1) type::fields, to obtain a pointer to the fields array (same as
   TYPE_FIELDS yields)
2) type::field, a new convenience method that obtains a reference to one
   of the type's field by index.  It is meant to replace

     TYPE_FIELDS (type)[idx]

   with

     type->field (idx)

gdb/ChangeLog:

	* gdbtypes.h (struct type) <field>: New method.
	(TYPE_FIELDS): Remove, replace all uses with either type::fields
	or type::field.

Change-Id: I49fba10114417deb502060c6156aa5f7fc62462f
2020-05-22 16:55:17 -04:00
Simon Marchi 3cabb6b069 gdb: add type::fields / type::set_fields
Add the `fields` and `set_fields` methods on `struct type`, in order to
remove the `TYPE_FIELDS` macro.  In this patch, the `TYPE_FIELDS` macro
is changed to the `type::fields`, so all the call sites that use it to
set the fields array are changed to use `type::set_fields`.  The next
patch will remove `TYPE_FIELDS` entirely.

gdb/ChangeLog:

	* gdbtypes.h (struct type) <fields, set_fields>: New methods.
	(TYPE_FIELDS): Use type::fields.  Change all call sites that
	modify the propery to use type::set_fields instead.

Change-Id: I05174ce68f2ce3fccdf5d8b469ff141f14886b33
2020-05-22 16:55:16 -04:00
Simon Marchi 1f704f761b gdb: remove TYPE_NFIELDS macro
Remove `TYPE_NFIELDS`, changing all the call sites to use
`type::num_fields` directly.  This is quite a big diff, but this was
mostly done using sed and coccinelle.  A few call sites were done by
hand.

gdb/ChangeLog:

	* gdbtypes.h (TYPE_NFIELDS): Remove.  Change all cal sites to use
	type::num_fields instead.

Change-Id: Ib73be4c36f9e770e0f729bac3b5257d7cb2f9591
2020-05-22 16:55:15 -04:00