Commit Graph

104072 Commits

Author SHA1 Message Date
Nick Clifton
ec3f28df02 Fix compile time warning building with gcc 11.
PR 26795
	* elfedit.c (process_archive): Remove spurious call to free().
2020-10-28 10:56:00 +00:00
Tom de Vries
364bb90300 [gdb/testsuite] Fix gdb.cp/nsalias.exp with -readnow
When running test-case gdb.cp/nsalias.exp with target board readnow, we get:
...
FAIL: gdb.cp/nsalias.exp: complaint for too many recursively imported \
  declarations
...

The complaint is not detected, because:
- the complaint is triggered during the file command instead of during
  "print N100::x"
- the "set complaints 1" is not effective because it's issued
  after the file command

Fix the FAIL by setting the complaints limit earlier, and detecting the
complaint also during the file command.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-10-28  Tom de Vries  <tdevries@suse.de>

	* lib/gdb.exp (gdb_file_cmd): Set gdb_file_cmd_msg.
	* gdb.cp/nsalias.exp: Set complaints limit before file cmd.  Expect
	complaint during file command for -readnow.
2020-10-28 10:01:32 +01:00
Tom de Vries
445a033f48 [gdb/testsuite] Fix typo in gdb.cp/nsalias.exp
Fix typo "compaint" -> "complaint".

gdb/testsuite/ChangeLog:

2020-10-28  Tom de Vries  <tdevries@suse.de>

	* gdb.cp/nsalias.exp: Fix typo in test name.
2020-10-28 10:01:32 +01:00
Tom de Vries
fdd67a422f [gdb/testsuite] Fix gdb.dwarf2/dw2-filename.exp with -readnow
When running test-case gdb.dwarf2/dw2-filename.exp with target board -readnow,
we run into:
...
FAIL: gdb.dwarf2/dw2-filename.exp: info sources
...

The normal output is:
...
(gdb) info sources^M
Source files for which symbols have been read in:^M
^M
Source files for which symbols will be read in on demand:^M
^M
src/gdb/testsuite/gdb.dwarf2/file1.txt^M
(gdb)
...
but with -readnow file1.txt appears in the "Source files for which symbols
have been read in" catagory instead, as expected.

Fix the FAIL by making the regexp match the -readnow output.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-10-28  Tom de Vries  <tdevries@suse.de>

	* gdb.dwarf2/dw2-filename.exp: Update regexp for -readnow.
2020-10-28 10:01:32 +01:00
Tom de Vries
706baf4c50 [gdb/testsuite] Fix gdb.dwarf2/dw2-stack-boundary.exp with -readnow
When running test-case gdb.dwarf2/dw2-stack-boundary.exp with target board
readnow, we run into:
...
FAIL: gdb.dwarf2/dw2-stack-boundary.exp: check partial symtab errors
...

The cause for the FAIL is that these complaints are not there:
...
During symbol reading: location description stack underflow^M
During symbol reading: location description stack overflow^M
...

Fix this by KFAILing the complaints for -readnow.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-10-28  Tom de Vries  <tdevries@suse.de>

	* gdb.dwarf2/dw2-stack-boundary.exp: KFAILing the complaints for
	-readnow.
2020-10-28 10:01:32 +01:00
GDB Administrator
e9bb6a60bf Automatic date update in version.in 2020-10-28 00:00:15 +00:00
Tom de Vries
b448cca522 [gdb/testsuite] Fix gdb.base/multi-forks.exp timeout with -readnow
When running test-case gdb.base/multi-forks.exp with target board readnow, we
run into:
...
FAIL: gdb.base/multi-forks.exp: run to exit 1 (timeout)
...

Fix this by using exp_continue.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-10-27  Tom de Vries  <tdevries@suse.de>

	* gdb.base/multi-forks.exp: Use exp_continue to fix timeout.
2020-10-27 23:17:09 +01:00
Tom de Vries
297e9a75f2 [gdb/testsuite] Fix DUPLICATEs in gdb.base/multi-forks.exp
When running test-case gdb.base/multi-forks.exp I get:
...
DUPLICATE: gdb.base/multi-forks.exp: run to exit 2
DUPLICATE: gdb.base/multi-forks.exp: run to exit 2
...

Fix these by using test_with_prefix.

Tested on x86_64-linux.
2020-10-27 23:17:09 +01:00
Tom de Vries
5868da034f [gdb/testsuite] Fix gdb.base/maint.exp FAILs with -readnow
When running test-case gdb.base/maint.exp with target board readnow, we run
into:
...
FAIL: gdb.base/maint.exp: mt expand-symtabs
FAIL: gdb.base/maint.exp: maint print objfiles: psymtabs
FAIL: gdb.base/maint.exp: maint print psymbols -source
FAIL: gdb.base/maint.exp: maint print psymbols -pc
FAIL: gdb.base/maint.exp: maint info line-table with filename of symtab that \
  is not currently expanded
...

When using -readnow:
- there are no partial symtabs
- all symtabs are expanded at symbol load time
and these differences from normal behaviour cause the FAILs.

Update the tests for -readnow.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-10-27  Tom de Vries  <tdevries@suse.de>

	* gdb.base/maint.exp: Update for -readnow.
2020-10-27 23:17:09 +01:00
Tom de Vries
06db6ec3d9 [gdb/testsuite] Fix gdb.cp/psymtab-parameter.exp with -readnow
When running test-case gdb.cp/psymtab-parameter.exp with target board readnow,
we run into:
...
FAIL: gdb.cp/psymtab-parameter.exp: maintenance info symtabs
...

The FAIL is expected, as mentioned in the comment:
...
 # The goal is to keep the CU (Compilation Unit) unexpanded.  It would be
 # rather XFAIL than FAIL here.  For example -readnow breaks it.
 gdb_test_no_output "maintenance info symtabs"
...

Fix the FAIL by skipping the command for -readnow.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-10-27  Tom de Vries  <tdevries@suse.de>

	* gdb.cp/psymtab-parameter.exp: Don't expect unexpanded CU for
	-readnow.
2020-10-27 23:17:09 +01:00
Gary Benson
934a176407 Fix gdb.python/py-format-string.exp with Clang
GDB includes the virtual table pointer when formatting polymorphic
C++ objects for printing, but GCC and Clang name these differently:
GCC emits a DW_AT_name of "_vptr.Base" when describing the virtual
table pointer of a type derived from type "Base", whereas Clang
will emit "_vptr$Base" in this situation.  This commit fixes a
testcase which failed because of this.

gdb/testsuite/ChangeLog:

	* gdb.python/py-format-string.exp (test_deref_refs): Treat
	"_vptr$Base" as correct, in addition to "_vptr.Base".
	(test_mixed): Likewise.
2020-10-27 17:02:39 +00:00
Gary Benson
0bf21fbd79 Add skip_fortran_tests to two Fortran testcases
This commit adds missing skip_fortran_tests checks to two Fortran
testcases that did not have it.  It also fixes a copy-paste error
in a comment.

gdb/testsuite/ChangeLog:

	* gdb.mi/mi-fortran-modules.exp: Check skip_fortran_tests.
	* gdb.mi/mi-vla-fortran.exp: Likewise.  Also fix a comment.
2020-10-27 16:54:38 +00:00
Nick Clifton
27e5e547c7 Fix seg-fault when running the ld testsuite for the hppa64-linux target.
* elf64-hppa.c (elf_hppa_final_link_relocate): Check that the
	symbol's section is being output before adding its offset to the
	addend when processing R_PARISC_SECREL32.
2020-10-27 16:23:09 +00:00
Nick Clifton
bcd213b2cf Fix the decoding of DW_FORM_ref_addr DWARF attribute.
* dwarf.c (struct abbrev_list): New structure.  Used to collect
	lists of abbreviation sets.
	(struct abbrev_map): New structure.  Used to map CU offsets to
	abbreviation offsets.
	(record_abbrev_list): New function.  A new entry to an
	abbreviation list.
	(free_all_abbrevs): Update to free abbreviation lists.
	(new_abbrev_list): New function.  Start a new abbreviation
	list.
	(find_abbrev_list_by_abbrev_offset): New function.
	(find_abbrev_map_by_offset): New function.
	(add_abbrev): Add abbrev_list parameter.
	(add_abbrev_attr): Likewise.
	(process_abbrev_section): Rename to process_abbrev_set and add
	list parameter.
	(get_type_abbrev_from_form): New function.  Attempts to decode the
	forms used by DW_AT_type attributes.
	(get_type_signedness): Display type names if operating in wide
	mode.  Use get_type_abbrev_from_form.
	(read_and_display_attr_value): Use get_type_abbrev_from_form.
	(process_debug_info): Pre-parse the CU headers to collate all the
	abbrevs before starting the main scan.
	(process_debug_abbrev): Do not free any loaded abbrevs.
	(free_debug_memory): Free the abbrev maps.
2020-10-27 16:17:13 +00:00
Simon Marchi
7f40ce1a9e gdb: remove unused includes in m32c-tdep.c
include-what-you-use says:

    ../../../src/binutils-gdb/gdb/m32c-tdep.c should remove these lines:
    - #include "dis-asm.h"  // lines 24-24
    - #include "dwarf2/expr.h"  // lines 31-31
    - #include "dwarf2/frame.h"  // lines 30-30
    - #include "elf-bfd.h"  // lines 21-21
    - #include "elf/m32c.h"  // lines 22-22
    - #include "target.h"  // lines 37-37
    - struct m32c_reg;  // lines 45-45

That looks right, remove them.  Tested by rebuilding.

gdb/ChangeLog:

	* m32c-tdep.c: Remove unused includes.

Change-Id: I28b41795f3bcc5406488dbf272c9e86fd5781b6b
2020-10-27 10:37:58 -04:00
Simon Marchi
5eb9e3f517 gdb: remove unused includes in xtensa-tdep.c
include-what-you-use says that these includes are not necessary in
xtensa-tdep.c:

    ../../../src/binutils-gdb/gdb/xtensa-tdep.c should remove these lines:
    - #include "dis-asm.h"  // lines 29-29
    - #include "dummy-frame.h"  // lines 36-36
    - #include "dwarf2.h"  // lines 37-37
    - #include "dwarf2/loc.h"  // lines 39-39
    - #include "inferior.h"  // lines 30-30
    - #include "objfiles.h"  // lines 25-25
    - #include "remote.h"  // lines 45-45
    - #include "serial.h"  // lines 46-46
    - #include "symfile.h"  // lines 24-24

That looks about right, so remove them.  Tested by re-building.

gdb/ChangeLog:

	* xtensa-tdep.c: Remove includes.

Change-Id: I9774ec59a68dd94e06967713d2f271b1760f6e6a
2020-10-27 10:28:27 -04:00
Tankut Baris Aktemur
b1d4d8d128 gdb/breakpoint: use gdb::option for the '-force' flag
Use the gdb::option framework for the '-force' flag of the 'condition'
command.  This gives tab-completion ability for the flag.

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

	* breakpoint.c (struct condition_command_opts): New struct.
	(condition_command_option_defs): New static global.
	(make_condition_command_options_def_group): New function.
	(condition_completer): Update to consider the '-force' flag.
	(condition_command): Use gdb::option for the '-force' flag.

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

	* gdb.base/condbreak.exp: Update the completion tests to
	consider the '-force' flag.
2020-10-27 15:02:17 +01:00
Tom de Vries
bd24c5d65b [gdb/testsuite] Fix section matching in find_pc_sect_compunit_symtab
When running test-case gdb.base/list-ambiguous.exp with target board readnow,
we run into:
...
FAIL: gdb.base/list-ambiguous.exp: list ambiguous_fun
...

The test-case contains two static functions ambiguous_fun, one in
list-ambiguous0.c and one in list-ambiguous1.c.

The list command is supposed to show both, but only the one from
list-ambiguous0.c is shown.

This is due to the section check in find_pc_sect_compunit_symtab.  It checks
whether the candidate compunit_symtab contains a symbol that has the required
section.  This check is only done for GLOBAL_BLOCK symbols.

The check succeeds for the compunit_symtab for list-ambiguous0.c, because it
contains main, but it fails for list-ambiguous0.c because it has no global
symbols.

Fix this by extending the section check to STATIC_BLOCK symbols.

Tested on x86_64-linux.

gdb/ChangeLog:

2020-10-27  Tom de Vries  <tdevries@suse.de>

	* symtab.c (find_pc_sect_compunit_symtab): Include STATIC_BLOCK
	symbols in section check.

gdb/testsuite/ChangeLog:

2020-10-27  Tom de Vries  <tdevries@suse.de>

	* gdb.base/list-ambiguous-readnow.exp: New file.
2020-10-27 13:28:27 +01:00
Tom de Vries
61eb46a4fb [gdb/symtab] Use early continue in find_pc_sect_compunit_symtab
Function find_pc_sect_compunit_symtab contains a loop:
...
  for (compunit_symtab *cust : obj_file->compunits ())
    {
      ...
      if (...)
        {
          /* Lots of code.  */
        }
    }
...

Reduce indentation level and improve readability by using early continue.

Tested on x86_64-linux.

gdb/ChangeLog:

2020-10-27  Tom de Vries  <tdevries@suse.de>

	* symtab.c (find_pc_sect_compunit_symtab): Use early continue.
2020-10-27 13:28:27 +01:00
Tankut Baris Aktemur
733d554a46 gdb/breakpoint: add flags to 'condition' and 'break' commands to force condition
The previous patch made it possible to define a condition if it's
valid at some locations.  If the condition is invalid at all of the
locations, it's rejected.  However, there may be cases where the user
knows the condition *will* be valid at a location in the future,
e.g. due to a shared library load.

To make it possible that such condition can be defined, this patch
adds an optional '-force' flag to the 'condition' command, and,
respectively, a '-force-condition' flag to the 'break'command.  When
the force flag is passed, the condition is not rejected even when it
is invalid for all the current locations (note that all the locations
would be internally disabled in this case).

For instance:

  (gdb) break test.c:5
  Breakpoint 1 at 0x1155: file test.c, line 5.
  (gdb) cond 1 foo == 42
  No symbol "foo" in current context.

Defining the condition was not possible because 'foo' is not
available.  The user can override this behavior with the '-force'
flag:

  (gdb) cond -force 1 foo == 42
  warning: failed to validate condition at location 1.1, disabling:
    No symbol "foo" in current context.
  (gdb) info breakpoints
  Num     Type           Disp Enb Address            What
  1       breakpoint     keep y   <MULTIPLE>
          stop only if foo == 42
  1.1                         N   0x0000000000001155 in main at test.c:5

Now the condition is accepted, but the location is automatically
disabled.  If a future location has a context in which 'foo' is
available, that location would be enabled.

For the 'break' command, -force-condition has the same result:

  (gdb) break test.c:5 -force-condition if foo == 42
  warning: failed to validate condition at location 0x1169, disabling:
    No symbol "foo" in current context.
  Breakpoint 1 at 0x1169: file test.c, line 5.

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

	* breakpoint.h (set_breakpoint_condition): Add a new bool parameter.
	* breakpoint.c: Update the help text of the 'condition' and 'break'
	commands.
	(set_breakpoint_condition): Take a new bool parameter
	to control whether condition definition should be forced even when
	the condition expression is invalid in all of the current locations.
	(condition_command): Update the call to 'set_breakpoint_condition'.
	(find_condition_and_thread): Take the "-force-condition" flag into
	account.
        * linespec.c (linespec_keywords): Add "-force-condition" as an
	element.
        (FORCE_KEYWORD_INDEX): New #define.
        (linespec_lexer_lex_keyword): Update to consider "-force-condition"
	as a keyword.
	* ada-lang.c (create_ada_exception_catchpoint): Ditto.
	* guile/scm-breakpoint.c (gdbscm_set_breakpoint_condition_x): Ditto.
	* python/py-breakpoint.c (bppy_set_condition): Ditto.
	* NEWS: Mention the changes to the 'break' and 'condition' commands.

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

	* gdb.base/condbreak-multi-context.exp: Expand to test forcing
	the condition.
	* gdb.linespec/cpcompletion.exp: Update to consider the
	'-force-condition' keyword.
	* gdb.linespec/explicit.exp: Ditto.
	* lib/completion-support.exp: Ditto.

gdb/doc/ChangeLog:
2020-10-27  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	* gdb.texinfo (Set Breaks): Document the '-force-condition' flag
	of the 'break'command.
	* gdb.texinfo (Conditions): Document the '-force' flag of the
	'condition' command.
2020-10-27 11:00:57 +01:00
Tankut Baris Aktemur
b5fa468fef gdb/breakpoint: disable a bp location if condition is invalid at that location
Currently, for a conditional breakpoint, GDB checks if the condition
can be evaluated in the context of the first symtab and line (SAL).
In case of an error, defining the conditional breakpoint is aborted.
This prevents having a conditional breakpoint whose condition may
actually be meaningful for some of the location contexts.  This patch
makes it possible to define conditional BPs by checking all location
contexts.  If the condition is meaningful for even one context, the
breakpoint is defined.  The locations for which the condition gives
errors are disabled.

The bp_location struct is introduced a new field, 'disabled_by_cond'.
This field denotes whether the location is disabled automatically
because the condition was non-evaluatable.  Disabled-by-cond locations
cannot be enabled by the user.  But locations that are not
disabled-by-cond can be enabled/disabled by the user manually as
before.

For a concrete example, consider 3 contexts of a function 'func'.

  class Base
  {
  public:
    int b = 20;

    void func () {}
  };

  class A : public Base
  {
  public:
    int a = 10;

    void func () {}
  };

  class C : public Base
  {
  public:
    int c = 30;

    void func () {}
  };

Note that

* the variable 'a' is defined only in the context of A::func.
* the variable 'c' is defined only in the context of C::func.
* the variable 'b' is defined in all the three contexts.

With the existing GDB, it's not possible to define a conditional
breakpoint at 'func' if the condition refers to 'a' or 'c':

  (gdb) break func if a == 10
  No symbol "a" in current context.
  (gdb) break func if c == 30
  No symbol "c" in current context.
  (gdb) info breakpoints
  No breakpoints or watchpoints.

With this patch, it becomes possible:

  (gdb) break func if a == 10
  warning: failed to validate condition at location 1, disabling:
    No symbol "a" in current context.
  warning: failed to validate condition at location 3, disabling:
    No symbol "a" in current context.
  Breakpoint 1 at 0x11b6: func. (3 locations)
  (gdb) break func if c == 30
  Note: breakpoint 1 also set at pc 0x11ce.
  Note: breakpoint 1 also set at pc 0x11c2.
  Note: breakpoint 1 also set at pc 0x11b6.
  warning: failed to validate condition at location 1, disabling:
    No symbol "c" in current context.
  warning: failed to validate condition at location 2, disabling:
    No symbol "c" in current context.
  Breakpoint 2 at 0x11b6: func. (3 locations)
  (gdb) info breakpoints
  Num     Type           Disp Enb Address            What
  1       breakpoint     keep y   <MULTIPLE>
          stop only if a == 10
  1.1                         N*  0x00000000000011b6 in Base::func() at condbreak-multi-context.cc:23
  1.2                         y   0x00000000000011c2 in A::func() at condbreak-multi-context.cc:31
  1.3                         N*  0x00000000000011ce in C::func() at condbreak-multi-context.cc:39
  2       breakpoint     keep y   <MULTIPLE>
          stop only if c == 30
  2.1                         N*  0x00000000000011b6 in Base::func() at condbreak-multi-context.cc:23
  2.2                         N*  0x00000000000011c2 in A::func() at condbreak-multi-context.cc:31
  2.3                         y   0x00000000000011ce in C::func() at condbreak-multi-context.cc:39
  (*): Breakpoint condition is invalid at this location.

Here, uppercase 'N' denotes that the location is disabled because of
the invalid condition, as mentioned with a footnote in the legend of
the table.  Locations that are disabled by the user are still denoted
with lowercase 'n'.  Executing the code hits the breakpoints 1.2 and
2.3 as expected.

Defining a condition on an unconditional breakpoint gives the same
behavior above:

  (gdb) break func
  Breakpoint 1 at 0x11b6: func. (3 locations)
  (gdb) cond 1 a == 10
  warning: failed to validate condition at location 1.1, disabling:
    No symbol "a" in current context.
  warning: failed to validate condition at location 1.3, disabling:
    No symbol "a" in current context.
  (gdb) info breakpoints
  Num     Type           Disp Enb Address            What
  1       breakpoint     keep y   <MULTIPLE>
          stop only if a == 10
  1.1                         N*  0x00000000000011b6 in Base::func() at condbreak-multi-context.cc:23
  1.2                         y   0x00000000000011c2 in A::func() at condbreak-multi-context.cc:31
  1.3                         N*  0x00000000000011ce in C::func() at condbreak-multi-context.cc:39
  (*): Breakpoint condition is invalid at this location.

Locations that are disabled because of a condition cannot be enabled
by the user:

  ...
  (gdb) enable 1.1
  Breakpoint 1's condition is invalid at location 1, cannot enable.

Resetting the condition enables the locations back:

  ...
  (gdb) cond 1
  Breakpoint 1's condition is now valid at location 1, enabling.
  Breakpoint 1's condition is now valid at location 3, enabling.
  Breakpoint 1 now unconditional.
  (gdb) info breakpoints
  Num     Type           Disp Enb Address            What
  1       breakpoint     keep y   <MULTIPLE>
  1.1                         y   0x00000000000011b6 in Base::func() at condbreak-multi-context.cc:23
  1.2                         y   0x00000000000011c2 in A::func() at condbreak-multi-context.cc:31
  1.3                         y   0x00000000000011ce in C::func() at condbreak-multi-context.cc:39

If a location is disabled by the user, a condition can still be defined
but the location will remain disabled even if the condition is meaningful
for the disabled location:

  ...
  (gdb) disable 1.2
  (gdb) cond 1 a == 10
  warning: failed to validate condition at location 1.1, disabling:
    No symbol "a" in current context.
  warning: failed to validate condition at location 1.3, disabling:
    No symbol "a" in current context.
  (gdb) info breakpoints
  Num     Type           Disp Enb Address            What
  1       breakpoint     keep y   <MULTIPLE>
          stop only if a == 10
  1.1                         N*  0x00000000000011b6 in Base::func() at condbreak-multi-context.cc:23
  1.2                         n   0x00000000000011c2 in A::func() at condbreak-multi-context.cc:31
  1.3                         N*  0x00000000000011ce in C::func() at condbreak-multi-context.cc:39
  (*): Breakpoint condition is invalid at this location.

The condition of a breakpoint can be changed.  Locations'
enable/disable states are updated accordingly.

  ...
  (gdb) cond 1 c == 30
  warning: failed to validate condition at location 1.1, disabling:
    No symbol "c" in current context.
  Breakpoint 1's condition is now valid at location 3, enabling.
  (gdb) info breakpoints
  Num     Type           Disp Enb Address            What
  1       breakpoint     keep y   <MULTIPLE>
          stop only if c == 30
  1.1                         N*  0x00000000000011b6 in Base::func() at condbreak-multi-context.cc:23
  1.2                         N*  0x00000000000011c2 in A::func() at condbreak-multi-context.cc:31
  1.3                         y   0x00000000000011ce in C::func() at condbreak-multi-context.cc:39
  (*): Breakpoint condition is invalid at this location.

  (gdb) cond 1 b == 20
  Breakpoint 1's condition is now valid at location 1, enabling.
  (gdb) info breakpoints
  Num     Type           Disp Enb Address            What
  1       breakpoint     keep y   <MULTIPLE>
          stop only if b == 20
  1.1                         y   0x00000000000011b6 in Base::func() at condbreak-multi-context.cc:23
  1.2                         n   0x00000000000011c2 in A::func() at condbreak-multi-context.cc:31
  1.3                         y   0x00000000000011ce in C::func() at condbreak-multi-context.cc:39
  # Note that location 1.2 was disabled by the user previously.

If the condition expression is bad for all the locations, it will be
rejected.

  (gdb) cond 1 garbage
  No symbol "garbage" in current context.

For conditions that are invalid or valid for all the locations of a
breakpoint, the existing behavior is preserved.

Regression-tested on X86_64 Linux.

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

	* breakpoint.h (class bp_location) <disabled_by_cond>: New field.
	* breakpoint.c (set_breakpoint_location_condition): New function.
	(set_breakpoint_condition): Disable a breakpoint location if parsing
	the condition string gives an error.
	(should_be_inserted): Update to consider the 'disabled_by_cond' field.
	(build_target_condition_list): Ditto.
	(build_target_command_list): Ditto.
	(build_bpstat_chain): Ditto.
	(print_one_breakpoint_location): Ditto.
	(print_one_breakpoint): Ditto.
	(breakpoint_1): Ditto.
	(bp_location::bp_location): Ditto.
	(locations_are_equal): Ditto.
	(update_breakpoint_locations): Ditto.
	(enable_disable_bp_num_loc): Ditto.
	(init_breakpoint_sal): Use set_breakpoint_location_condition.
	(find_condition_and_thread_for_sals): New static function.
	(create_breakpoint): Call find_condition_and_thread_for_sals.
	(location_to_sals): Call find_condition_and_thread_for_sals instead
	of find_condition_and_thread.

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

	* gdb.base/condbreak-multi-context.cc: New file.
	* gdb.base/condbreak-multi-context.exp: New file.

gdb/doc/ChangeLog:
2020-10-27  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	* gdb.texinfo (Set Breaks): Document disabling of breakpoint
	locations for which the breakpoint condition is invalid.
2020-10-27 10:58:45 +01:00
GDB Administrator
afeee87bdc Automatic date update in version.in 2020-10-27 00:00:09 +00:00
H.J. Lu
e7f8dd4a14 ld: Pass -fno-lto in ld-elfweak/elfweak.exp
* testsuite/ld-elfweak/elfweak.exp: Pass $NOLTO_CFLAGS to CC.
2020-10-26 16:45:35 -07:00
Tom Tromey
b324727682 Fix some minor bugs in test suite command logging
I noticed that the test suite command logging would create a file like
"gdb.cmd.-1".  I tracked this down to a substraction in
standard_output_file_with_gdb_instance.

Then, I saw that the .in file was not created for MI.  This is fixed
by adding a call to default_mi_gdb_start.

Finally, commands might not end up in the .in file in some cases.  For
me this happened because the test took a long time, so I got impatient
and killed it.  Flushing the file after each write seemed like a good
thing to do here.

gdb/testsuite/ChangeLog
2020-10-26  Tom Tromey  <tom@tromey.com>

	* lib/mi-support.exp (default_mi_gdb_start): Call
	gdb_stdin_log_init.
	* lib/gdb.exp (standard_output_file_with_gdb_instance): Don't
	subtract one from gdb_instances.
	(gdb_stdin_log_write): Flush in_file.
2020-10-26 17:10:25 -06:00
Tom de Vries
1c47ec3ee8 [gdb/symtab] Read CU base address for enqueued CU
Consider the test-case contained in this patch.  It consists of
two CUs:
- cu1, containing a DW_TAG_variable DIE foo
- cu2, containing a DW_TAG_base_type DIE int
where the variable foo has type int, in other words, there's an inter-CU
reference.

When expanding the symtab for cu1, expansion of the symtab for cu2 is
enqueued, and later processed by process_full_comp_unit.  However, processing
of .debug_ranges fails because the range is specified relative to a base
address which is considered not to be present because
!cu->base_address.has_value (), and we run into this case in
dwarf2_ranges_process:
...
      if (!base.has_value ())
        {
          /* We have no valid base address for the ranges
             data.  */
          complaint (_("Invalid .debug_ranges data (no base address)"));
          return 0;
        }
...

Fix this in process_full_comp_unit by setting cu->base_address.

Tested on x86_64-linux.

gdb/ChangeLog:

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

	* dwarf2/read.c (process_full_comp_unit): Call
	dwarf2_find_base_address.

gdb/testsuite/ChangeLog:

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

	* gdb.dwarf2/enqueued-cu-base-addr.exp: New file.
2020-10-26 20:28:47 +01:00
Tom Tromey
6390859caa Don't inherit range-type signed-ness from underlying type
A recent commit changed gdb to inherit the signed-ness of a range type
from its underlying type:

    commit cfabbd351a
    Author: Tom Tromey <tom@tromey.com>
    Date:   Sat Oct 17 11:41:59 2020 -0600

      Make range types inherit signed-ness from base type

This passed testing -- but unfortunately, additional testing at
AdaCore showed that this change was incorrect.  GNAT, at least, can
emit an unsigned range type whose underlying type is signed.

This patch reverts the code change from the above.  I chose not to
reintroduce the FIXME comments, because now we know that they are
incorrect.  Instead, this patch also adds a comment to
create_range_type.

A new test case is included as well.

2020-10-26  Tom Tromey  <tromey@adacore.com>

	* gdbtypes.c (create_range_type): Revert previous patch.  Add
	comment.

gdb/testsuite/ChangeLog
2020-10-26  Tom Tromey  <tromey@adacore.com>

	* gdb.ada/unsigned_range/foo.adb: New file.
	* gdb.ada/unsigned_range/pack.adb: New file.
	* gdb.ada/unsigned_range/pack.ads: New file.
	* gdb.ada/unsigned_range.exp: New file.
2020-10-26 13:00:41 -06:00
Pedro Alves
d744f0f965 gdb::handle_eintr, remove need to specify return type
This eliminates the need to specify the return type when using
handle_eintr.  We let the compiler deduce it for us.

Also, use lowercase for function parameter names.  Uppercase should
only be used on template parameters.

gdb/ChangeLog:

	* nat/linux-waitpid.c: Include "gdbsupport/eintr.h".
	(my_waitpid): Use gdb::handle_eintr.

gdbserver/ChangeLog:

	* netbsd-low.cc (netbsd_waitpid, netbsd_process_target::kill)
	(netbsd_qxfer_libraries_svr4): Use gdb::handle_eintr without
	explicit type.

gdbsupport/ChangeLog:

	* eintr.h (handle_eintr): Replace Ret template parameter with
	ErrorValType.  Use it as type of the failure value.  Deduce the
	function's return type using decltype.  Use lowercase for function
	parameter names.
2020-10-26 18:57:40 +00:00
Tom de Vries
55c3ad8801 [gdb/testsuite] Prevent pagination in GDB_INTERNALFLAGS
When running test-case gdb.base/corefile.exp with target board readnow, we run
into:
...
Reading symbols from outputs/gdb.base/corefile/corefile...^M
Expanding full symbols from outputs/gdb.base/corefile/corefile...^M
[New LWP 2293]^M
Core was generated by `outputs/gdb.base/corefile/co'.^M
Program terminated with signal SIGABRT, Aborted.^M
--Type <RET> for more, q to quit, c to continue without paging--\
  FAIL: gdb.base/corefile.exp: (timeout) starting with -core
...

In commit bd447abb24 "Make gdb.base/corefile.exp work on terminals with few
rows", pagination (in the same test-case) is prevented using:
...
set stty_init "rows 25 cols 80"
...
but this doesn't work in our case because using -readnow adds an extra line
"Expanding full symbols".

The test passes when increasing rows to 26.  However, increasing the rows by
some n only fixes the problem for n lines, and things will break again if
somehow we end up with n + 1 lines.

Instead, fix this by setting heigth and width in INTERNAL_GDBFLAGS.  This
solution was not chosen in commit bd447abb24 because it doesn't handle
pagination due to the introduction text.  But it does handle the pagination
due to the extra "Expanding full symbols", and any other line printed during
and after file loading.

Tested on x86_64-linux, with and without readnow.

With -readnow, fixes timeout FAILs in gdb.base/corefile.exp and
gdb.base/reread-readsym.exp.

gdb/testsuite/ChangeLog:

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

	* lib/gdb.exp (INTERNAL_GDBFLAGS): Set heigth and width.
2020-10-26 16:05:15 +01:00
H.J. Lu
ae9d2233e6 gas: Clear all auto-assigned file slots
Since a file slot is auto-assigned for the #APP marker appeared before
the first .file <NUMBER> directive has been seen, clear all auto-assigned
file slots when seeing the first .file <NUMBER> directive.

	PR gas/26778
	* * dwarf2dbg.c (num_of_auto_assigned): New.
	(allocate_filenum): Increment num_of_auto_assigned.
	(dwarf2_directive_filename): Clear the slots auto-assigned
	before the first .file <NUMBER> directive was seen.
	* testsuite/gas/i386/dwarf4-line-1.d: New file.
	* testsuite/gas/i386/dwarf4-line-1.s: Likewise.
	* testsuite/gas/i386/i386.exp: Run dwarf4-line-1.
2020-10-26 06:16:21 -07:00
Nick Clifton
93cf38c095 Invoke the linker's error handling script with the keyword "undefined-symbol" when using it to help with undefined symbol errors.
PR 26626
	* ldmain.c (undefined_symbol): Use the keyword undefined-symbol
	when invoking the error handling script for undefined symbols.
	* ld.texi: Update documentation.
2020-10-26 12:39:50 +00:00
Tom de Vries
1612c4bbcb [gdb/testsuite] Add missing ranges base in dw2-objfile-overlap-*.S
When doing a gdb testsuite run with this trigger patch:
...
@@ -14454,6 +14454,7 @@ dwarf2_ranges_process

       if (!base.has_value ())
        {
+         gdb_assert (false);
          /* We have no valid base address for the ranges
             data.  */
          complaint (_("Invalid .debug_ranges data (no base address)"));
...
we run into the assert with test-case gdb.dwarf2/dw2-objfile-overlap.exp.

Fix this by adding the missing .debug_ranges base in
gdb.dwarf2/dw2-objfile-overlap-*.S.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

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

	* gdb.dwarf2/dw2-objfile-overlap-inner.S: Specify default base address
	for CU.
	* gdb.dwarf2/dw2-objfile-overlap-outer.S: Same.
2020-10-26 11:08:38 +01:00
Lifang Xia
7e300b8612 Update gas/ChangeLog of last commit
gas/
	* ChangeLog: Update ChangLog of 2e58f3923e
2020-10-26 18:03:22 +08:00
Cooper Qu
2e58f3923e C-SKY: Fix the literal dump of big vector constant.
gas/
	* config/tc-csky.c (dump_literals): Fix the literal dump of big
	vector constant.
2020-10-26 17:17:53 +08:00
Cooper Qu
1b03c32c3b CSKY: Change default linker script for elf toolchain.
ld/
	* emulparams/cskyelf.sh (TEXT_START_ADDR): Change to 0x60000000.
	(DATA_ADDR) : Define.
	(OTHER_SYMBOLS) : Define.
	(OTHER_BSS_SYMBOLS) : Set symbol __sbss__.
	(OTHER_BSS_END_SYMBOLS) : Set symbol __ebss__.
	* ld/emulparams/cskyelf_linux.sh : Don't include cskyelf.sh.
	* testsuite/ld-csky/data.d : Fix '/s*' to match spaces.
	* testsuite/ld-csky/hilo16.d : Likewise.

Change-Id: Ia29b32eab4157ae5be0fc0b6125fb5b7d9dac939
2020-10-26 17:13:21 +08:00
Cooper Qu
eae61d61e9 CSKY: Change plsl.u16 to plsl.16.
gas/
	* testsuite/gas/csky/enhance_dsp.s : Change plsl.u16 to plsl.16.
	* testsuite/gas/csky/enhance_dsp.d : Change plsl.u16 to plsl.16.

opcodes/
	* csky-opc.h (csky_v2_opcodes): Change plsl.u16 to plsl.16.

Change-Id: Ifb43573192e215527355f6541365b9f6a8ec80a4
2020-10-26 16:26:32 +08:00
Cooper Qu
9d1ccf22fd CSKY: Add version flag in eflag and fix bug in disassembling register.
gas/
	* config/tc-csky.c (md_begin): Add version flag in eflag.

include/
	* opcode/csky.h (CSKY_VERSION_V1): Define, currently used.
	(CSKY_VERSION_V2): Define.
	(CSKY_VERSION_V3): Define.

Change-Id: Iafe3a9ce6fe544880a225b9fae439275a828bb34
2020-10-26 16:20:10 +08:00
Cooper Qu
039dac293d CSKY: Fix and add some instructions for VDSPV1.
gas/
	* config/tc-csky.c (get_operand_value): Add handler for
	OPRND_TYPE_IMM5b_VSH and OPRND_TYPE_VREG_WITH_INDEX.
	* testsuite/gas/csky/csky_vdsp.d : Fix the disassembling
	for vector register.

opcodes/
	* csky-dis.c (csky_output_operand): Add handler for
	OPRND_TYPE_IMM5b_VSH and OPRND_TYPE_VREG_WITH_INDEX.
	* csky-opc.h (OPRND_TYPE_VREG_WITH_INDEX): New enum.
	(OPRND_TYPE_IMM5b_VSH): New enum.
	(csky_v2_opcodes): Fix and add some instructions for VDSPV1.

Change-Id: Ia5675d7b716fe5c331e6121ad8f83061ef6454bb
2020-10-26 16:13:55 +08:00
Cui,Lili
069ef16480 Change avxvnni disassembler output from {vex3} to {vex}
gas/

	* testsuite/gas/i386/avx-vnni.d: Change psuedo prefix from
	{vex3} to {vex}
	* testsuite/gas/i386/x86-64-avx-vnni.d: Likewise.

opcodes/

	* i386-dis.c: Change "XV" to print "{vex}" pseudo prefix.
2020-10-26 10:51:55 +08:00
Simon Marchi
006811bc02 gdb: move ptrace.m4 to gdbsupport
ptrace.m4, providing the GDB_AC_PTRACE autoconf macro, is used by gdb,
gdbserver and gdbsupport.  I think it would make sense to move it to
gdbsupport.

gdb/ChangeLog:

	* acinclude.m4: Update ptrace.m4 path.
	* ptrace.m4: Moved to gdbsupport.

gdbserver/ChangeLog:

	* acinclude.m4: Update ptrace.m4 path.

gdbsupport/ChangeLog:

	* Makefile.in: Re-generate.
	* acinclude.m4: Update ptrace.m4 path.
	* ptrace.m4: Move here.

Change-Id: I849c149fd5dd8c3b2b0af38654fb353e3727871b
2020-10-25 21:08:49 -04:00
GDB Administrator
02855c3a54 Automatic date update in version.in 2020-10-26 00:00:07 +00:00
Simon Marchi
c75e31a1ec gdb: use inferior parameter in add_vsyscall_page
Use the new inferior parameter instead of target_gdbarch.  There are
still hidden references to the current context behind core_bfd and
exec_bfd, but this seemed better than nothing.

gdb/ChangeLog:

	* symfile-mem.c (add_vsyscall_page): Use inferior parameter
	instead of target_gdbarch.

Change-Id: Iaf5ace555ee8e46cbef5190aca1f6fe639f06677
2020-10-25 09:06:09 -04:00
Simon Marchi
324956617c gdb: make jit.c use the inferior_created inferior parameter
Use the inferior parameter now available in jit_inferior_created_hook.
It is passed down to jit_inferior_init, which uses it as much as
possible instead of the current inferior or current program space.

gdb/ChangeLog:

	* jit.c (jit_reader_load_command): Pass current inferior.
	(jit_inferior_init): Change parameter type to inferior, use it.
	(jit_inferior_created): Remove.
	(jit_inferior_created_hook): Pass inferior parameter down.
	(_initialize_jit): Use jit_inferior_created_hook instead of
	jit_inferior_created.
	* jit.h (jit_inferior_created_hook): Add inferior parameter.
	* infrun.c (follow_exec): Pass inferior to
	jit_inferior_created_hook.

Change-Id: If3a2114a933370dd313d5abd623136d273cdb8fa
2020-10-25 09:06:09 -04:00
Simon Marchi
3f66685e9e gdb: pass inferior to check_pid_namespace_match
Pass the inferior argument available in thread_db_inferior_created, and
use it to do most things requiring the inferior.
check_pid_namespace_match is not completely decoupled from the current
inferior yet, there are hidden references behind target_can_run, for
example.  But I think this is still a good step forward.

gdb/ChangeLog:

	* linux-thread-db.c (check_pid_namespace_match): Add inferior
	parameter and use it.
	(thread_db_inferior_created): Pass inferior argument.

Change-Id: Ib768b14fc61dcf115fe13f776691f2c2f36e0679
2020-10-25 09:06:09 -04:00
Simon Marchi
a0ff652f4c gdb: add inferior parameter to inferior_created observable
I think it would make sense for the inferior_created observable to say
which inferior is being dealt with, rather than relying on it being the
current inferior.

This patch adds an inferior parameter to inferior_created, but does not
change the callbacks to use it.

gdb/ChangeLog:

	* aix-thread.c (aix_thread_inferior_created): Add inferior
	parameter.
	* bsd-uthread.c (bsd_uthread_inferior_created): Likewise.
	* dummy-frame.c (cleanup_dummy_frames): Likewise.
	* jit.c (jit_inferior_created): Likewise.
	* linux-thread-db.c (thread_db_inferior_created): Likewise.
	* m68k-linux-tdep.c (m68k_linux_inferior_created): Likewise.
	* observable.h (inferior_created): Likewise.
	* ravenscar-thread.c (ravenscar_inferior_created): Likewise.
	* symfile-mem.c (add_vsyscall_page): Likewise.
	* infcmd.c (post_create_inferior): Pass inferior argument.

Change-Id: I2543d19ff055a9df6b269929faea10b27d2adc5e
2020-10-25 09:06:09 -04:00
Alan Modra
0c70050a4b asan: alpha-vms: buffer overflow
* vms-misc.c (_bfd_vms_save_counted_string): Count length byte
	towards maxlen.
2020-10-25 22:25:45 +10:30
GDB Administrator
4690795539 Automatic date update in version.in 2020-10-25 00:00:14 +00:00
Simon Marchi
92a048fd3b gdbserver: re-generate configure
I get this diff when I re-generate the configure script in gdbserver,
probably leftovers from e911c6663b ("Require kinfo_get_file and
kinfo_get_vmmap for FreeBSD hosts").

gdbserver/ChangeLog:

	* config.in: Re-generate.
	* configure: Re-generate.

Change-Id: Id19a72ea9f3e7c7b4fdb0f319c9c0bbad0e39aeb
2020-10-24 12:44:19 -04:00
Joel Brobecker
3c67532c05 Document the GDB 10.1 release in gdb/ChangeLog
gdb/ChangeLog:

	GDB 10.1 released.
2020-10-24 08:36:42 +04:00
GDB Administrator
c1df719408 Automatic date update in version.in 2020-10-24 00:00:13 +00:00
H.J. Lu
72d813f35e ld: Set plug_opt only if compiler is available
* testsuite/config/default.exp (plug_opt): Set only if compiler
	is available.
2020-10-23 11:25:15 -07:00