Commit Graph

103229 Commits

Author SHA1 Message Date
Simon Marchi
e46d3488de gdb: remove TYPE_STUB
gdb/ChangeLog:

	* gdbtypes.h (TYPE_STUB): Remove, replace all
	uses with type::is_stub.

Change-Id: Iec25b50449a0d10a38f815209e478c343e98632c
2020-09-14 11:07:59 -04:00
Simon Marchi
b4b7375953 gdb: add type::is_stub / type::set_is_stub
Add the `is_stub` and `set_is_stub` methods on `struct type`, in order
to remove the `TYPE_STUB` macro.  In this patch, the macro is changed to
use the getter, so all the call sites of the macro that are used as a
setter are changed to use the setter method directly.  The next patch
will remove the macro completely.

gdb/ChangeLog:

	* gdbtypes.h (struct type) <is_stub, set_is_stub>: New methods.
	(TYPE_STUB): Use type::is_stub, change all write call sites to
	use type::set_is_stub.

Change-Id: Ie935e8fe72c908afd8718411e83f4ff00c386bf3
2020-09-14 11:07:58 -04:00
Simon Marchi
20ce41238d gdb: remove TYPE_NOSIGN
gdb/ChangeLog:

	* gdbtypes.h (TYPE_NOSIGN): Remove, replace all uses with
	type::has_no_signedness.

Change-Id: Iaf8d1cedad195d03a4358e90f6ada77290d03bf2
2020-09-14 11:07:58 -04:00
Simon Marchi
15152a54ae gdb: add type::has_no_signedness / type::set_has_no_signedness
Add the `has_no_signedness` and `set_has_no_signednes` methods on `struct
type`, in order to remove the `TYPE_NOSIGN` macro.  In this patch, the macro is
changed to use the getter, so all the call sites of the macro that are used as
a setter are changed to use the setter method directly.  The next patch will
remove the macro completely.

gdb/ChangeLog:

	* gdbtypes.h (struct type) <has_no_signedness,
	set_has_no_signedness>: New methods.
	(TYPE_NOSIGN): Use type::has_no_signedness, change all write
	call sites to use type::set_has_no_signedness.

Change-Id: I80d8e774316d146fbd814b2928ad5392bada39d5
2020-09-14 11:07:57 -04:00
Simon Marchi
c6d940a956 gdb: remove TYPE_UNSIGNED
gdb/ChangeLog:

	* gdbtypes.h (TYPE_UNSIGNED): Remove, replace all uses with
	type::is_unsigned.

Change-Id: I84f76f5cd44ff7294e421d317376a9e476bc8666
2020-09-14 11:07:57 -04:00
Simon Marchi
653223d356 gdb: add type::is_unsigned / type::set_is_unsigned
Add the `is_unsigned` and `set_is_unsigned` methods on `struct type`, in
order to remove the `TYPE_UNSIGNED` macro.  In this patch, the
`TYPE_UNSIGNED` macro is changed to use `type::is_unsigned`, so all the
call sites that are used to set this property on a type are changed to
use the new method.  The next patch will remove the macro completely.

gdb/ChangeLog:

	* gdbtypes.h (struct type) <is_unsigned, set_is_unsigned>: New
	methods.
	(TYPE_UNSIGNED): Use type::is_unsigned.  Change all write call
	sites to use type::set_is_unsigned.

Change-Id: Ib09ddce84eda160a801a8f288cccf61c8ef136bc
2020-09-14 11:07:56 -04:00
Fredrik Hederstierna
55ea94da36 Fix exception stack unwinding for ARM Cortex-M
For Cortex-M targets using floating-point, eg the Cortex-M4F, its not possible
to get any call-stack backtrace if setting a breakpoint in ISR.

The exception stack unwinder for Cortex-M does not consider if floating-point
registers was stacked or not, further the Cortex-M has two stack pointers: MSP
(Main Stack Pointer) and PSP (Process Stack Pointer).
This is not handled when GDB tries to backtrace in the exception stack
unwinder.

This patch fixes this, and gives a correct call-stack backtrace from
breakpoints set in a handler or ISR.

gdb/ChangeLog:

        * arm-tdep.c (arm_m_exception_cache): Try use correct stack
        pointer and stack frame offset when unwinding.
2020-09-14 15:26:12 +01:00
Cooper Qu
74fea55bb7 CSKY: Set feature flags for default cpu.
Fix floating point instructions not recognized when building GCC.

gas/
	PR 26608
	* config/tc-csky.c (md_begin): Set feature flags for default
	cpu.
2020-09-14 20:26:57 +08:00
Tom de Vries
ee6372f211 [gdb/testsuite] Fix PATH warning in gdb.rust/traits.exp
When running the rust test-cases with release 1.36.0 and LLVM version 7.0, I
run into:
...
(gdb) UNTESTED: gdb.rust/traits.exp: could not read \
  outputs/gdb.rust/traits/traits with readelf
PATH: gdb.rust/traits.exp: could not read \
  outputs/gdb.rust/traits/traits with readelf
...

Fix the PATH warning by printing [file tail $binfile] instead $binfile.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

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

	* gdb.rust/traits.exp: Fix PATH warning.
2020-09-14 09:54:47 +02:00
GDB Administrator
1e95aa3b80 Automatic date update in version.in 2020-09-14 00:00:14 +00:00
Pedro Alves
dc3a371e83 gdb/testsuite: Explicitly return from main
I've been playing with a board file that forces every testcase to
include a header file that does something like:

  #define main __gdb_testcase_main

and then links an actual main() function that does some
initialization and then jumps to __gdb_testcase_main.

That runs into a number of testcases relying on main not having an
explicit return statement, like e.g.,:

 gdb/build/gdb/testsuite/../../../src/gdb/testsuite/gdb.base/catch-follow-exec.c:27:1: warning: non-void function does not return a value [-Wreturn-type]
 gdb/build/gdb/testsuite/../../../src/gdb/testsuite/gdb.base/catch-signal.c:47:1: warning: non-void function does not return a value [-Wreturn-type]

We don't get those warnings without my board because it is valid to
not explicitly return from main.  There's an implicit "return 0;".

Since it doesn't hurt to be explicit, I've went ahead and added the
explicit return statements.

Also, a couple testcases either don't explicitly specify main's return
type, or return void.  Those are tweaked to explicitly return int.

gdb/testsuite/ChangeLog:

	* gdb.base/catch-follow-exec.c (main): Add explicit return
	statement.
	* gdb.base/catch-signal.c (main): Likewise.
	* gdb.base/condbreak-call-false.c (main): Likewise.
	* gdb.base/consecutive.c (main): Add explicit return
	statement and return type.
	* gdb.base/cursal.c (main): Add explicit return statement.
	* gdb.base/cvexpr.c (main): Likewise.
	* gdb.base/display.c (main): Add explicit return statement and
	return type.
	* gdb.base/dprintf-detach.c (main): Add explicit return statement.
	* gdb.base/endianity.c (main): Likewise.
	* gdb.base/execd-prog.c (main): Likewise.
	* gdb.base/gdb1090.c (main): Likewise.
	* gdb.base/info_qt.c (main): Likewise.
	* gdb.base/lineinc.c (main): Likewise.
	* gdb.base/load-command.c (main): Likewise.
	* gdb.base/macscp1.c (main): Likewise.
	* gdb.base/pr10179-a.c (main): Likewise.
	* gdb.base/quit-live.c (main): Likewise.
	* gdb.base/scope0.c (main): Likewise.
	* gdb.base/settings.c (main): Likewise.
	* gdb.base/stack-checking.c (main): Return int.
	* gdb.base/varargs.c (main): Add explicit return statement.
	* gdb.cp/ambiguous.cc (main): Likewise.
	* gdb.cp/anon-struct.cc (main): Likewise.
	* gdb.cp/anon-union.cc (main): Likewise.
	* gdb.cp/bool.cc (main): Likewise.
	* gdb.cp/bs15503.cc (main): Likewise.
	* gdb.cp/cplusfuncs.cc (main): Likewise.
	* gdb.cp/cttiadd.cc (main): Likewise.
	* gdb.cp/extern-c.cc (main): Likewise.
	* gdb.cp/filename.cc (main): Likewise.
	* gdb.cp/formatted-ref.cc (main): Likewise.
	* gdb.cp/mb-ctor.cc (main): Likewise.
	* gdb.cp/member-ptr.cc (main): Likewise.
	* gdb.cp/minsym-fallback-main.cc (main): Likewise.
	* gdb.cp/overload-const.cc (main): Likewise.
	* gdb.cp/paren-type.cc (main): Likewise.
	* gdb.cp/parse-lang.cc (main): Likewise.
	* gdb.cp/pr-1023.cc (main): Likewise.
	* gdb.cp/psmang1.cc (main): Likewise.
	* gdb.cp/readnow-language.cc (main): Likewise.
	* gdb.cp/ref-params.cc (main): Likewise.
	* gdb.cp/rvalue-ref-params.cc (main): Likewise.
	* gdb.cp/virtbase2.cc (main): Likewise.
	* gdb.dwarf2/dw2-abs-hi-pc.c (main): Likewise.
	* gdb.dwarf2/dw2-namespaceless-anonymous.c (main): Likewise.
	* gdb.dwarf2/dw4-toplevel-types.cc (main): Likewise.
	* gdb.mi/mi-console.c (main): Likewise.
	* gdb.mi/mi-read-memory.c (main): Likewise.
	* gdb.modula2/multidim.c (main): Likewise.
	* gdb.opt/inline-small-func.c (main): Likewise.
	* gdb.python/py-rbreak.c (main): Likewise.
	* gdb.stabs/exclfwd1.c (main): Likewise.
	* gdb.trace/qtro.c (main): Likewise.
2020-09-13 22:47:01 +01:00
Pedro Alves
af26601c2f Fix gdb.base/share-env-with-gdbserver.exp with Clang
The testcase has GDB call my_getenv in the inferior, and that fails
with Clang, because Clang optimizes out my_getenv completely, since it
isn't called anywhere (in the program).

This commit fixes it.

gdb/testsuite/ChangeLog:

	* gdb.base/share-env-with-gdbserver.c (main): Call my_getenv
	instead of getenv.
2020-09-13 21:28:09 +01:00
Pedro Alves
2f4b83cd51 Make default_mi_gdb_start/dbx_gdb_start use gdb_spawn
If a board file wants to customize how gdb is launched, the obvious
way is to have the board override gdb_spawn.  However, that doesn't
work for either gdb.mi/ testcases or gdb.base/dbx.exp, because
default_mi_gdb_start and dbx_gdb_start don't use gdb_spawn currently.

That is fixed by this patch.

gdb/testsuite/

	* gdb.base/dbx.exp (dbx_gdb_start): Adjust to use gdb_spawn
	instead of spawning GDB with remote_spawn.
	* lib/mi-support.exp (default_mi_gdb_start): Adjust to use
	gdb_spawn instead of spawning GDB with remote_spawn.
2020-09-13 20:31:25 +01:00
Pedro Alves
c49da0e466 Fix a couple gdb.dwarf2/ testcases with "clang -flto"
gdb.dwarf2/atomic-type.exp and gdb.dwarf2/ada-linkage-name.exp fail
when testing with "clang -flto" as compiler, like:

 $ make check TESTS="gdb.dwarf2/ada-linkage-name.exp" RUNTESTFLAGS="CC_FOR_TARGET='clang -flto'"

because with -flto, functions that aren't referenced anywhere are not
emitted in the final binary.  Fix it by adding uses of the functions.

gdb/testsuite/ChangeLog:

	* gdb.dwarf2/ada-linkage-name.c (main): Move to the bottom of the
	file and add calls to first and second.
	* gdb.dwarf2/atomic.c (main): Move to the bottom of the file and
	add call to f.
2020-09-13 18:17:18 +01:00
Pedro Alves
6791b1172a Add MI "-break-insert --qualified"
Currently -break-insert always creates a wildmatching breakpoint, and
there's no way to ask for a fullname match.  To address that, this
patch adds the equivalent of "break -qualified" to MI:

  "-break-insert --qualified".

For the testcase, curiously, it doesn't look like we have _any_
testcase that tests a breakpoint with multiple locations, and, the
existing mi_create_breakpoint / mi_make_breakpoint procedures are only
good for breakpoints with a single location.  This patch thus adds a
few new companion routines to mi-support.exp for breakpoints with
multiple locations: mi_create_breakpoint_multi,
mi_make_breakpoint_loc, mi_make_breakpoint_multi.

gdb/ChangeLog:

	* NEWS: Document "-break-insert --qualified".
	* mi/mi-cmd-break.c (mi_cmd_break_insert_1): Handle "--qualified".

gdb/doc/ChangeLog:

	* gdb.texinfo (GDB/MI Breakpoint Commands): Document
	"-break-insert --qualified" and "-dprintf-insert --qualified".

gdb/testsuite/ChangeLog:

	* gdb.mi/mi-break-qualified.cc: New file.
	* gdb.mi/mi-break-qualified.exp: New file.
	* lib/mi-support.exp (mi_create_breakpoint_multi)
	(mi_make_breakpoint_loc, mi_make_breakpoint_multi): New
	procedures.
	(mi_create_breakpoint_1): New, factored out from
	mi_create_breakpoint.
2020-09-13 18:02:19 +01:00
Pedro Alves
3b8d4c5cc0 Remove stale "register" bits from gdb.cp/misc.cc
gdb.cp/misc.cc seems to have been originally copied from
gdb.cp/classes.cc.  The testcases that use it, misc.exp and
inherit.exp don't reference the "register" bits anywhere.  Remove
them, since they trigger warnings with newer GCCs, given "register" is
being removed in C++17.

gdb/testsuite/ChangeLog:

	* gdb.cp/inherit.exp: No longer pass -Wno-deprecated-register.
	* gdb.cp/misc.exp: No longer pass -Wno-deprecated-register.
	* gdb.cp/misc.cc (class small, small::method, marker_reg1)
	(register_class): Delete.
	(main): Don't call register_class.
2020-09-13 15:46:21 +01:00
Pedro Alves
d5f96005a6 Move "register" test out of classes.exp to a separate testcase
The gdb.cp/classes.exp testcase has one test that tries to exercise
the case of calling a method on a variable that has been put in a
register.

See the declaration of small in classes.cc:

/* Try to get the compiler to allocate a class in a register.  */
class small {
 public:
  int x;
  int method ();
};

and the comment in classes.exp:

    # This class is so small that an instance of it can fit in a register.
    # When gdb tries to call a method, it gets embarrassed about taking
    # the address of a register.
    #
    # TODO: I think that message should be a PASS, not an XFAIL.
    # gdb prints an informative message and declines to do something
    # impossible.
    #
    # The method call actually succeeds if the compiler allocates very
    # small classes in memory instead of registers.  So this test does
    # not tell us anything interesting if the call succeeds.
    #
    # -- chastain 2003-12-31

And these comments:

 https://gcc.gnu.org/legacy-ml/gcc/2010-05/msg00116.html
 https://gcc.gnu.org/legacy-ml/gcc/2010-05/msg00117.html

 "register keyword has other uses, e.g. for -O0 code variables
 declared with register keyword can be put into registers, while
 variables declared without it always get stack slots."

 "I think it does, without optimization.  There's some unique GDB
 tests that use this.  It causes them to be live between statements in
 a machine register instead of always stored in stack slots."

The "register" keyword seems to be ignored by the compiler nowadays
even at -O0, though.  With or without the register keyword, the
variable is given a stack slot, at least on x86-64 with GCC 9.

However, if we use the GCC extension to put the variable
in a specific variable:

 https://gcc.gnu.org/onlinedocs/gcc-10.2.0/gcc/Local-Register-Variables.html#Local-Register-Variables

 diff --git c/gdb/testsuite/gdb.cp/classes.cc w/gdb/testsuite/gdb.cp/classes.cc
 index 5ea360e4d06..6dcf34689b8 100644
 --- c/gdb/testsuite/gdb.cp/classes.cc
 +++ w/gdb/testsuite/gdb.cp/classes.cc
 @@ -629,7 +629,7 @@ register_class ()
    /* We don't call any methods for v, so gcc version cygnus-2.3.3-930220
       might put this variable in a register.  This is a lose, though, because
       it means that GDB can't call any methods for that variable.  */
 -  register small v;
 +  register small v asm ("rax");

then it works, and we get an XFAIL:

 print v.method ()
 Address requested for identifier "v" which is in register $rax
 (gdb) XFAIL: gdb.cp/classes.exp: calling method for small class (PRMS 2972)

I think that what we should do here is move this test into its own
file, use that GCC syntax to force it to a register, and do as the
comment says -- issue a pass instead of an XFAIL.

That's what this commit does.

Note that we don't need -Wno-deprecated-register (nor -Wno-register)
anymore in the new testcase, because GNU register-asm local variables
don't trigger the warning, with either GCC or Clang.

gdb/testsuite/ChangeLog:

	* gdb.cp/classes.exp: No longer pass -Wno-deprecated-register.
	(do_tests): Remove "calling method for small class" test.
	* gdb.cp/classes.cc (class small, small::method, marker_reg1)
	(register_class): Delete.
	(main): Don't call register_class.
	* gdb.cp/call-method-register.exp: New file, based on bits removed
	from classes.exp.
	* gdb.cp/call-method-register.cc: New file, based on bits removed
	from classes.cc.
2020-09-13 15:36:00 +01:00
Pedro Alves
77f2120b20 Don't drop static function bp locations w/o debug info
Currently, with a program built from these sources:

 $ cat extern.c
 void foo () {}
 $ cat static.c
 static void foo () {}
 $ cat main.c
 int main () { return 0; }

... if you set a breakpoint on "foo", like:

 (gdb) break foo

.. when there's debug info, GDB creates a breakpoint with two
locations, one for each of the external and static functions.

But, when there's no debug info, GDB creates a breakpoint with a
single location, for the external foo.  Vis:

 $ gcc extern.c static.c main.c -o classify.nodebug
 $ gcc extern.c static.c main.c -o classify.debug -g

 $ gdb classify.nodebug
 Reading symbols from classify.nodebug...
 (No debugging symbols found in classify.nodebug)
 (gdb) b foo
 Breakpoint 1 at 0x40048b
 (gdb) info breakpoints
 Num     Type           Disp Enb Address            What
 1       breakpoint     keep y   0x000000000040048b <foo+4>
 (gdb)

 $ gdb classify.debug
 Reading symbols from classify.debug...
 (gdb) b foo
 Breakpoint 1 at 0x40048b: foo. (2 locations)
 (gdb) info breakpoints
 Num     Type           Disp Enb Address            What
 1       breakpoint     keep y   <MULTIPLE>
 1.1                         y   0x000000000040048b in foo at extern.c:1
 1.2                         y   0x0000000000400492 in foo at static.c:1

GDB drops the static function is search_minsyms_for_name, where at the
very end of that function we pick only the locations with highest
classification, according to classify_type.

The classify_type logic was introduced here:

  https://sourceware.org/pipermail/gdb-patches/2011-December/087864.html

which said:

 "Previously, linespec was trying to filter out minsyms as they were
  seen.  However, this isn't faithful to gdb's historical approach,
  which is to priority-order minsyms; see lookup_minimal_symbol."

lookup_minimal_symbol's intro says, in the .c file:

/* Look through all the current minimal symbol tables and find the
   first minimal symbol that matches NAME.  If OBJF is non-NULL, limit
   the search to that objfile.  If SFILE is non-NULL, the only file-scope
   symbols considered will be from that source file (global symbols are
   still preferred).  Returns a pointer to the minimal symbol that
   matches, or NULL if no match is found.

   Note:  One instance where there may be duplicate minimal symbols with
   the same name is when the symbol tables for a shared library and the
   symbol tables for an executable contain global symbols with the same
   names (the dynamic linker deals with the duplication).

   It's also possible to have minimal symbols with different mangled
   names, but identical demangled names.  For example, the GNU C++ v3
   ABI requires the generation of two (or perhaps three) copies of
   constructor functions --- "in-charge", "not-in-charge", and
   "allocate" copies; destructors may be duplicated as well.
   Obviously, there must be distinct mangled names for each of these,
   but the demangled names are all the same: S::S or S::~S.  */

struct bound_minimal_symbol
lookup_minimal_symbol (const char *name, const char *sfile,
		       struct objfile *objf)
{

If you look inside this function, you'll see:

  /* External symbols are best.  */
...
  /* File-local symbols are next best.  */
...
  /* Symbols for shared library trampolines are next best.  */
...

While this logic is good when you're looking for the single "best"
symbol by name, I question it for linespecs, since we want to set
breakpoints in all the multiple locations that match.  I see no point
in hidding static functions.

Now, for breakpoints, it does make sense to filter out PLT/trampoline
symbols if we find the actual global matching function symbol.
Otherwise, if we did no filtering (i.e., just removed the
classify_type logic), you would end up with e.g.:

 (gdb) b printf
 Breakpoint 1 at 0x413a60 (2 locations)
 (top-gdb) info breakpoints
 Num     Type           Disp Enb Address            What
 1      breakpoint     keep y   <MULTIPLE>
 1.1                         y   0x0000000000413a60 <printf@plt>
 1.2                         y   0x00007ffff4653640 in __printf at printf.c:28

instead of this (which is what we get currently) before the shared
library is loaded (a location set in the PLT):

 (gdb) b printf
 Breakpoint 1 at 0x413a60
 Num     Type           Disp Enb Address            What
 1       breakpoint     keep y   0x0000000000413a60 <printf@plt>

and this after the library is loaded (only one location, no breakpoint
in the PLT):

 (gdb) b printf
 Breakpoint 1 at 0x7ffff4653640: file printf.c, line 28.
 (gdb) info breakpoints
 Num     Type           Disp Enb Address            What
 1       breakpoint     keep y   0x00007ffff4653640 in __printf at printf.c:28

This patch fixes the missing breakpoint locations issue by replacing
the classify_type logic in linespec.c with a different logic.
Instead, discard a trampoline symbol if we also found a
global/external symbol with the same name.  The patch adds a couple of
testcases testing locations in external vs static functions vs
trampolines/PLTs.

We now get:

For the msym-bp.exp testcase (extern vs static), without debug info:

 (gdb) info breakpoints
 Num     Type           Disp Enb Address            What
 1       breakpoint     keep y   <MULTIPLE>
 1.1                         y   0x000000000040048b <foo+4>          ### missing before patch
 1.2                         y   0x000000000040049d <foo+4>

For the msym-bp.exp testcase (extern vs static), with debug info:

 (gdb) info breakpoints
 Num     Type           Disp Enb Address            What
 1       breakpoint     keep y   <MULTIPLE>
 1.1                         y   0x000000000040048b in foo at src/gdb/testsuite/gdb.base/msym-bp.c:21
 1.2                         y   0x000000000040049d in foo at src/gdb/testsuite/gdb.base/msym-bp-2.c:21

For the msym-bp-shl.exp testcase (static vs plt), without debug info, before running to main:

 (gdb) info breakpoints
 Num     Type           Disp Enb Address            What
 1       breakpoint     keep y   <MULTIPLE>
 1.1                         y   0x00000000004004e0 <foo@plt>        ### missing before patch
 1.2                         y   0x00000000004005db <foo+4>

For the msym-bp-shl.exp testcase (static vs plt), without debug info, after running to main:

 (gdb) info breakpoints
 Num     Type           Disp Enb Address            What
 1       breakpoint     keep y   <MULTIPLE>
 1.1                         y   0x00000000004005db <foo+4>          ### missing before patch
 1.2                         y   0x00007ffff7bd65de <foo+4>

For the msym-bp-shl.exp testcase (static vs plt), with debug info, before running to main:

 (gdb) info breakpoints
 Num     Type           Disp Enb Address            What
 1       breakpoint     keep y   <MULTIPLE>
 1.1                         y   0x00000000004004e0 <foo@plt>        ### missing before patch
 1.2                         y   0x00000000004005db in foo at src/gdb/testsuite/gdb.base/msym-bp-shl-main-2.c:21

For the msym-bp-shl.exp testcase (static vs plt), with debug info, after running to main:

 (gdb) info breakpoints
 Num     Type           Disp Enb Address            What
 1       breakpoint     keep y   <MULTIPLE>
 1.1                         y   0x00000000004005db in foo at src/gdb/testsuite/gdb.base/msym-bp-shl-main-2.c:21
 1.2                         y   0x00007ffff7bd65de in foo at src/gdb/testsuite/gdb.base/msym-bp-shl-lib.c:21

gdb/ChangeLog:

	* linespec.c (classify_mtype, compare_msyms): Delete.
	(search_minsyms_for_name): Remove classification logic.  Instead
	filter out trampoline symbols if we also found an external
	function of the same name.

gdb/testsuite/ChangeLog:

	* gdb.base/msym-bp-2.c: New.
	* gdb.base/msym-bp-shl-lib.c: New file.
	* gdb.base/msym-bp-shl-main-2.c: New file.
	* gdb.base/msym-bp-shl-main.c: New file.
	* gdb.base/msym-bp-shl.exp: New file.
	* gdb.base/msym-bp.c: New file.
	* gdb.base/msym-bp.exp: New file.
2020-09-13 13:34:10 +01:00
Alan Modra
1f656a652e Re: elf: Add -z unique-symbol
PR 26391
	* testsuite/ld-elf/pr26391.nd: Adjust to match powerpc64 function
	descriptors.
2020-09-13 18:42:12 +09:30
Joel Brobecker
ed6a896ca6 Update NEWS post GDB 10 branch creation.
gdb/ChangeLog:

	* NEWS: Create a new section for the next release branch.
	Rename the section of the current branch, now that it has
	been cut.
2020-09-12 19:43:47 -07:00
Joel Brobecker
32aea73e01 Bump version to 11.0.50.DATE-git.
Now that the GDB 10 branch has been created, we can
bump the version number.

gdb/ChangeLog:

	GDB 10 branch created (8087c3fa8b):
	* version.in: Bump version to 11.0.50.DATE-git.

gdb/testsuite/ChangeLog:

	* gdb.base/default.exp: Change $_gdb_major to 11.
2020-09-12 19:34:28 -07:00
GDB Administrator
320f5391b6 Automatic date update in version.in 2020-09-13 00:00:14 +00:00
Joel Brobecker
8087c3fa8b Fix GDB build in infrun.c when configured with unit tests disabled
I noticed this while testing the GDB in the context of the upcoming
GDB 10 release branching, because part of the process involves setting
development to False, which in turn changes the default for including
unittest to false as well. As a result, without this patch, we get
compilation errors in infrun.c such as:

    infrun.c:9219:5: error: `scoped_mock_context' was not declared in this scope

This patch fixes it by bracketing the unitttest in namespace selftest
with an #if GDB_SELF_TEST.

gdb/ChangeLog:

        * infrun.c (namespace selftests): Only define #if GDB_SELF_TEST.

Tested on x86_64-linux, with and without self-tests.
2020-09-12 12:38:35 -07:00
H.J. Lu
496afd1705 elf: Add -z unique-symbol to avoid duplicated local symbol names
The symbol string table in the .symtab section is optional and cosmetic.
The contents of the .symtab section have no impact on run-time execution.
The symbol names in the symbol string table help distinguish addresses at
different locations.  Add a linker option, -z unique-symbol, to avoid
duplicated local symbol names in the symbol string table.

This feature was well received by the livepatch maintainers.  It not only
solves the duplicated local symbol name problem, but also would allow
livepatch to more precisely locate duplicate symbols in general for
patching.

bfd/

	PR ld/26391
	* elflink.c (elf_final_link_info): Add local_hash_table.
	(local_hash_entry): New.
	(local_hash_newfunc): Likewise.
	(elf_link_output_symstrtab): Append ".COUNT" to duplicated local
	symbols.
	(bfd_elf_final_link): Initialize and free local_hash_table for
	"-z unique-symbol".

include/

	PR ld/26391
	* bfdlink.h (bfd_link_info): Add unique_symbol.

ld/

	PR ld/26391
	* NEWS: Mention "-z unique-symbol".
	* emultempl/elf.em (gld${EMULATION_NAME}_handle_option): Handle
	"-z unique-symbol" and "-z nounique-symbol".
	* ld.texi: Document "-z unique-symbol" and "-z nounique-symbol".
	* lexsup.c (elf_static_list_options): Add "-z unique-symbol" and
	"-z nounique-symbol".
	* testsuite/ld-elf/elf.exp: Add PR ld/26391 tests.
	* testsuite/ld-elf/pr26391.nd: New file.
	* testsuite/ld-elf/pr26391.out: Likewise.
	* testsuite/ld-elf/pr26391a.c: Likewise.
	* testsuite/ld-elf/pr26391b.c: Likewise.
	* testsuite/ld-elf/pr26391c.c: Likewise.
	* testsuite/ld-elf/pr26391d.c: Likewise.
2020-09-12 05:37:43 -07:00
GDB Administrator
e71774ed24 Automatic date update in version.in 2020-09-12 00:00:07 +00:00
Felix Willgerodt
2a67f09db1 Add bfloat16 support for AVX512 register view.
This adds support for the bfloat16 datatype, which can be seen as a short
version of FP32, skipping the least significant 16 bits of the mantissa.
Since the datatype is currently only supported by the AVX512 registers,
the printing of bfloat16 values is only supported for xmm, ymm and zmm
registers.

gdb/ChangeLog:
2020-09-11  Moritz Riesterer  <moritz.riesterer@intel.com>
	    Felix Willgerodt  <Felix.Willgerodt@intel.com>

	* gdbarch.sh: Added bfloat16 type.
	* gdbarch.c: Regenerated.
	* gdbarch.h: Regenerated.
	* gdbtypes.c (floatformats_bfloat16): New struct.
	(gdbtypes_post_init): Add builtin_bfloat16.
	* gdbtypes.h (struct builtin_type) <builtin_bfloat16>: New member.
	(floatformats_bfloat16): New struct.
	* i386-tdep.c (i386_zmm_type): Add field "v32_bfloat16"
	(i386_ymm_type): Add field "v16_bfloat16"
	(i386_gdbarch_init): Add set_gdbarch_bfloat16_format.
	* target-descriptions.c (make_gdb_type): Add case TDESC_TYPE_BFLOAT16.
	* gdbsupport/tdesc.cc (tdesc_predefined_types): New member bfloat16.
	* gdbsupport/tdesc.h (tdesc_type_kind): New member TDESC_TYPE_BFLOAT16.
	* features/i386/64bit-avx512.xml: Add bfloat16 type.
	* features/i386/64bit-avx512.c: Regenerated.
	* features/i386/64bit-sse.xml: Add bfloat16 type.
	* features/i386/64bit-sse.c: Regenerated.

gdb/testsuite/ChangeLog:
2020-09-11  Moritz Riesterer  <moritz.riesterer@intel.com>
	    Felix Willgerodt  <Felix.Willgerodt@intel.com>

	* x86-avx512bf16.c: New file.
	* x86-avx512bf16.exp: Likewise.
	* lib/gdb.exp (skip_avx512bf16_tests): New function.
2020-09-11 11:42:47 -07:00
Felix Willgerodt
1347d11109 i386-tdep: Fix naming in zmm and ymm type descriptions.
gdb/Changelog:
2020-07-02  Felix Willgerodt  <felix.willgerodt@intel.com>

	* i386-tdep.c (i386_zmm_type): Fix field names.
	(i386_ymm_type): Fix field names.
2020-09-11 11:36:14 -07:00
Felix Willgerodt
dae7c5a444 Sync include, libiberty with GCC.
include:
2020-09-10  Felix Willgerodt  <felix.willgerodt@intel.com>

    Sync with GCC
    2020-08-17  Felix Willgerodt  <felix.willgerodt@intel.com>

    * floatformat.h (floatformat_bfloat16_big): New.
    (floatformat_bfloat16_little): New.

libiberty:
2020-09-10  Felix Willgerodt  <felix.willgerodt@intel.com>

    Sync with GCC
    2020-08-17  Felix Willgerodt  <felix.willgerodt@intel.com>

    * floatformat.c (floatformat_bfloat16_big): New.
    (floatformat_bfloat16_little): New.
2020-09-11 11:32:00 -07:00
Mark Wielaard
edc7a80a9c gas: Don't error when .debug_line already exists, unless .loc was used
When -g was used to generate DWARF gas would error out when a .debug_line
already exists. But when a .debug_info section already exists it would
simply skip generating one without warning or error. Do the same for
.debug_line. It is only an error when the user explicitly uses .loc
directives and also generates the .debug_line table itself.

The tests are unfortunately arch specific because the line table is only
generated when actual instructions have been emitted. Use i386 because
that is probably the most used architecture. Before this patch the new
dwarf-line-2 testcase would fail, with this patch it succeeds (and doesn't
try to add its own line table).

gas/ChangeLog:

    * as.texi (-g): Explicitly mention when .debug_info and .debug_line
    are generated for the DWARF format.
    (Loc): Add that it is an error to both use a .loc directive and
    generate a .debug_line yourself.
    * dwarf2dbg.c (dwarf2_any_loc_directive_seen): New static variable.
    (dwarf2_directive_loc): Set dwarf2_any_loc_directive_seen to TRUE.
    (dwarf2_finish): Check dwarf2_any_loc_directive_seen before emitting
    an error. Only create .debug_line if it is empty (or doesn't exist).
    * testsuite/gas/i386/i386.exp: Add dwarf2-line-{1,2,3,4} when testing
    an elf target.
    * testsuite/gas/i386/dwarf2-line-{1,2,3,4}.{s,d,l}: New test files.
2020-09-11 19:18:44 +02:00
Cooper Qu
548f527578 CSKY: Change ISA flag's type to bfd_uint64_t and fix build error.
The previous patch missed one modification.
Following is the error message:
gas/config/tc-csky.c:806:5: error: 'CSKY_ARCH_804' undeclared here
(not in a function); did you mean 'CSKY_ARCH_807'?

include/
	* opcode/csky.h (CSKYV1_ISA_E1): Convert to bfd_uint64_t type.
	(CSKYV2_ISA_E1): Likewise.
	(CSKYV2_ISA_1E2): Likewise.
	(CSKYV2_ISA_2E3): Likewise.
	(CSKYV2_ISA_3E7): Likewise.
	(CSKYV2_ISA_7E10): Likewise.
	(CSKYV2_ISA_3E3R1): Likewise.
	(CSKYV2_ISA_3E3R2): Likewise.
	(CSKYV2_ISA_10E60): Likewise.
	(CSKYV2_ISA_3E3R3): Likewise.
	(CSKY_ISA_TRUST): Likewise.
	(CSKY_ISA_CACHE): Likewise.
	(CSKY_ISA_NVIC): Likewise.
	(CSKY_ISA_CP): Likewise.
	(CSKY_ISA_MP): Likewise.
	(CSKY_ISA_MP_1E2): Likewise.
	(CSKY_ISA_JAVA): Likewise.
	(CSKY_ISA_MAC): Likewise.
	(CSKY_ISA_MAC_DSP): Likewise.
	(CSKY_ISA_DSP): Likewise.
	(CSKY_ISA_DSP_1E2): Likewise.
	(CSKY_ISA_DSP_ENHANCE): Likewise.
	(CSKY_ISA_DSPE60): Likewise.
	(CSKY_ISA_FLOAT_E1): Likewise.
	(CSKY_ISA_FLOAT_1E2): Likewise.
	(CSKY_ISA_FLOAT_1E3): Likewise.
	(CSKY_ISA_FLOAT_3E4): Likewise.
	(CSKY_ISA_FLOAT_7E60): Likewise.
	(CSKY_ISA_VDSP): Likewise.
	(CSKY_ISA_VDSP_2): Likewise.
	(CSKY_ARCH_804): Define.
	(CSKY_ARCH_805): Define.
	(CSKY_ARCH_800): Define.
2020-09-12 00:56:01 +08:00
Jeremy Drake
9cdc5bacdd Fix a segfault when creating an import library with 0 exports.
PR 26588
	* emultempl/pe.em (_finish): Only generate a import library if not
	exporting relocs.
	* emultempl/pep.em: Likewise.
2020-09-11 17:51:16 +01:00
Tom de Vries
ad570dd76c [gdb/testsuite] Kfail gdb.cp/ambiguous.exp FAILs for PR26602
Kfail these FAILs as caused by PR exp/26602:
...
FAIL: gdb.cp/ambiguous.exp: print x.x
FAIL: gdb.cp/ambiguous.exp: print n.x
FAIL: gdb.cp/ambiguous.exp: print j.x
FAIL: gdb.cp/ambiguous.exp: print jva1.x
FAIL: gdb.cp/ambiguous.exp: print jva2.x
FAIL: gdb.cp/ambiguous.exp: print (A1)j
FAIL: gdb.cp/ambiguous.exp: print (A1)jva1
...

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-09-11  Tom de Vries  <tdevries@suse.de>

	PR exp/26602
	* gdb.cp/ambiguous.exp: Add KFAILs for PR26602.
2020-09-11 15:56:44 +02:00
H.J. Lu
8d58ed37f1 x86: Add NT_X86_CET note
Define NT_X86_CET which is the proposed note for x86 CET state to support
Intel CET in Linux kernel.  Double check it after Intel CET patches have
been merged into Linux kernel.

binutils/

	* readelf.c (get_note_type): Support NT_X86_CET.

include/

	* elf/common.h (NT_X86_CET): New.
2020-09-11 05:52:06 -07:00
Nick Clifton
ce139cd560 Fix the debuglink following code to recursively load links found in the newly loaded debug info.
PR 26595
	* dwarf.c (load_separate_debug_info): Return NULL rather than
	FALSE in error situations.
	(load_separate_debug_file): Move code to load debug links to ...
	(check_for_and_load_links): ... here.  New function.  Load
	separate debug information pointed to by debuglink and
	debugaltlink sections.  Recursively scan newly loaded debug
	information for more links and load them too.
2020-09-11 13:30:56 +01:00
Tankut Baris Aktemur
7a4e8e7d55 gdb/breakpoint: fix typo in help message of "set breakpoint condition-evaluation"
The options for the "breakpoint condition-evaluation" setting are
"host", "target", and "auto".  The help message mentions the option
"gdb" at one point instead of "host".  Fix this typo.  Also add a period.

gdb/ChangeLog:
2020-09-11  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	* breakpoint.c: Fix typo in the help message of the
	"set breakpoint condition-evaluation" command.
2020-09-11 13:50:09 +02:00
Tankut Baris Aktemur
a56f73917a gdb/testsuite: remove stale comment in gdb.base/bp-cmds-execution-x-script.exp
Remove a stale command that is apparently forgotten after a copy-paste
from 'gdb.base/break-main-file-remove-fail.exp'.

gdb/testsuite/ChangeLog:
2020-09-11  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	* gdb.base/bp-cmds-execution-x-script.exp: Remove a stale comment.
2020-09-11 13:44:09 +02:00
GDB Administrator
580decb024 Automatic date update in version.in 2020-09-11 00:00:13 +00:00
Siddhesh Poyarekar
c7cd291722 aarch64: Return an error on conditional branch to an undefined symbol
The fix in 7e05773767 introduced a PLT
for conditional jumps when the target symbol is undefined.  This is
incorrect because conditional branch relocations are not allowed to
clobber IP0/IP1 and hence, should not result in a dynamic relocation.

Revert that change and in its place, issue an error when the target
symbol is undefined.

bfd/

	2020-09-10  Siddhesh Poyarekar  <siddesh.poyarekar@arm.com>

	* elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Revert
	changes in 7e05773767.  Set
	error for undefined symbol in BFD_RELOC_AARCH64_BRANCH19 and
	BFD_RELOC_AARCH64_TSTBR14 relocations.

ld/

	2020-09-10  Siddhesh Poyarekar  <siddesh.poyarekar@arm.com>

	* testsuite/ld-aarch64/emit-relocs-560.d: Expect error instead
	of valid output.
2020-09-10 21:42:37 +05:30
H.J. Lu
93d49941ed ld: Add more tests for --as-needed
Prior to

commit 1e3b96fd6c
Author: Alan Modra <amodra@gmail.com>
Date:   Fri Sep 4 13:54:21 2020 +0930

    Allow plugin syms to mark as-needed shared libs needed

when removing unused IR symbol references, ld didn't add unnecessary
DT_NEEDED libraries which may lead to undefined symbol reference in a
--as-needed library when the symbol is defined in a prior --as-needed
library and there is no reference in relocatable inputs.  This behavior
is desirable since it ensures that both lazy and non-lazy bindings work
the same way.  The problem is with --as-needed libraries, which happens
with and without LTO.  Now, the linker may add many unnecessary DT_NEEDED
libraries for IR inputs.

	PR ld/26590
	* testsuite/ld-elf/pr26590.err: New file.
	* testsuite/ld-elf/pr26590a.c: Likewise.
	* testsuite/ld-elf/pr26590b.c: Likewise.
	* testsuite/ld-elf/pr26590c.c: Likewise.
	* testsuite/ld-elf/pr26590d.c: Likewise.
	* testsuite/ld-elf/shared.exp: Run ld/26590 tests.
2020-09-10 07:52:20 -07:00
Alan Modra
918619e5e5 PR26597, FAIL: gdb.dlang/demangle.exp: _D8demangle4testFI5identZv
gcc commit 387d0773f3 changed the D demangler, with the following
commit log:

    libiberty: Add support for `in' and `in ref' storage classes.

    The storage class `in' is now a first-class citizen with its own mangle
    symbol, of which also permits `in ref'.  Previously, `in' was an alias
    to `const [scope]', which is a type constructor.

    The mangle symbol repurposed for this is `I', which was originally used
    by identifier types.  However, while TypeIdentifier is part of the
    grammar, it must be resolved to some other entity during the semantic
    passes, and so shouldn't appear anywhere in the mangled name.

    Old tests that are now no longer valid have been removed.

This patch makes the same changes to the gdb testsuite as were made to
the upstream gcc libiberty testsuite.

gdb/testsuite/
	PR 26597
	* gdb.dlang/demangle.exp: Update tests as per gcc commit 387d0773f3.
2020-09-10 23:57:56 +09:30
Kamil Rytarowski
62ba50486f Add minimal and functional NetBSD/amd64 gdbserver
Implement the following functionality: create_inferior,
post_create_inferior, attach, kill, detach, mourn, join, thread_alive,
resume, wait, fetch_registers, store_registers, read_memory, write_memory,
request_interrupt, supports_read_auxv, read_auxv,
supports_hardware_single_step, sw_breakpoint_from_kind,
supports_z_point_type, insert_point, remove_point,
stopped_by_sw_breakpoint, supports_qxfer_siginfo, qxfer_siginfo,
supports_stopped_by_sw_breakpoint, supports_non_stop,
supports_multi_process, supports_fork_events, supports_vfork_events,
supports_exec_events, supports_disable_randomization,
supports_qxfer_libraries_svr4, qxfer_libraries_svr4,
supports_pid_to_exec_file, pid_to_exec_file, thread_name,
supports_catch_syscall.

The only CPU architecture supported: x86_64.

Implement only support for hardware assisted single step and
software breakpoint.

Implement support only for regular X86 registers, thus no FPU.

gdbserver/ChangeLog:

       * netbsd-low.cc: Add.
       * netbsd-low.h: Likewise.
       * netbsd-amd64-low.cc: Likewise.
       * Makefile.in (SFILES): Register "netbsd-low.cc", "netbsd-low.h",
       "netbsd-amd64-low.cc".
       * configure.srv: Add x86_64-*-netbsd*.
2020-09-10 15:40:10 +02:00
Kamil Rytarowski
cf4ac4be12 Switch local native code to gdb/nat shared functions
No functional change as the same functionality inlined in nbsd-nat.c
is offered in gdb/nat/netbsd-nat.c.

gdb/ChangeLog:

	* nbsd-nat.c: Include "nat/netbsd-nat.h".
	* (nbsd_nat_target::pid_to_exec_file)
	(nbsd_nat_target::thread_alive, nbsd_nat_target::thread_name)
	(nbsd_nat_target::post_startup_inferior)
	(nbsd_nat_target::post_attach, nbsd_nat_target::xfer_partial)
	(nbsd_add_threads): Switch local code to common gdb/nat functions.
	* (nbsd_pid_to_cmdline): Call sysctl from the global namespace.
	* (nbsd_thread_lister): Remove.
2020-09-10 15:39:45 +02:00
Kamil Rytarowski
f404573e4f Avoid double free in startup_inferior
Do not free the last execd pathname as it will be used in
prepare_resume_reply(), after attaching a client side.

gdb/ChangeLog:

	* fork-inferior.c (startup_inferior): Avoid double free.
2020-09-10 15:39:19 +02:00
Kamil Rytarowski
1ccb2c170c Add a common utility function to read and write siginfo_t in inferior
gdb/ChangeLog:

        * netbsd-nat.h (netbsd_nat::qxfer_siginfo): Add.
        * netbsd-nat.c (netbsd_nat::qxfer_siginfo): Likewise.
2020-09-10 15:38:57 +02:00
Kamil Rytarowski
feedfcc773 Add netbsd_nat::enable_proc_events in gdb/nat
Add generic function to enable debugger events in a process.

gdb/ChangeLog:

        * netbsd-nat.h (netbsd_nat::enable_proc_events): Add.
	* netbsd-nat.c: Include <sys/ptrace.h>.
	* (netbsd_nat::enable_proc_events): Add.
2020-09-10 15:38:23 +02:00
Kamil Rytarowski
c489f8c6e6 Add gdb/nat common functions for listing threads
Add netbsd_nat::netbsd_thread_lister a generic thread lister, used
internally in netbsd-nat.c, copied from gdb/nbsd-nat.c.

Add public extern functions for listing threads:
 * netbsd_nat::thread_alive
 * netbsd_nat::thread_name
 * netbsd_nat::for_each_thread

gdb/ChangeLog:

	* netbsd-nat.h: Include "gdbsupport/function-view.h".
	* (netbsd_nat::thread_alive, netbsd_nat::thread_name)
	(netbsd_nat::for_each_thread): Add.
	* netbsd-nat.c: Include "gdbsupport/common-defs.h" and
	"gdbsupport/common-debug.h".
	* (netbsd_nat::netbsd_thread_lister)
	(netbsd_nat::thread_alive, netbsd_nat::thread_name)
	(netbsd_nat::for_each_thread): Add.
2020-09-10 15:37:52 +02:00
Kamil Rytarowski
330662f684 Add netbsd_nat::pid_to_exec_file
gdb/ChangeLog:

        * netbsd-nat.h: Include <unistd.h>.
        * (netbsd_nat::pid_to_exec_file): Add.
        * netbsd-nat.c: Include <sys/types.h> and <sys/sysctl.h>.
        * (netbsd_nat::pid_to_exec_file) Add.
2020-09-10 15:37:32 +02:00
Kamil Rytarowski
70b67307e9 Build nat/netbsd-nat.o for the NetBSD native target
gdb/ChangeLog:

	* configure.nat (NATDEPFILES): Add nat/netbsd-nat.o when needed.
2020-09-10 15:36:27 +02:00
Kamil Rytarowski
99cf6da66a Register a placeholder for NetBSD shared functions in gdb/nat
gdb/ChangeLog:

	* netbsd-nat.h: New file.
	* netbsd-nat.c: Likewise.
2020-09-10 15:35:51 +02:00
Kamil Rytarowski
48c9b43332 Add handle_eintr to wrap EINTR handling in syscalls
gdbsupport/ChangeLog:

	* eintr.h: New file.
2020-09-10 15:35:12 +02:00