]> sourceware.org Git - binutils-gdb.git/log
binutils-gdb.git
4 years agoEnsure that space allocated by assembler directives converts from an octet count...
Nick Clifton [Fri, 18 Sep 2020 12:28:46 +0000 (13:28 +0100)]
Ensure that space allocated by assembler directives converts from an octet count to a byte count.

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

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

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

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

gdb/testsuite/ChangeLog:

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

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

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

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

gdb/testsuite/ChangeLog:

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

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

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

gdb/testsuite/ChangeLog:

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

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

Make the testcase buildable with a C++ compiler.

gdb/testsuite/ChangeLog:

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

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

Fixes:

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

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

gdb/testsuite/ChangeLog:

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

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

gdb/testsuite/ChangeLog:

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

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

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

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

gdb/testsuite/ChangeLog:

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

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

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

key_t is renamed because of:

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

gdb/testsuite/ChangeLog:

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

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

This adjusts:

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

to make them buildable as C++ programs.

gdb/testsuite/ChangeLog:

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

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

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

gdb/testsuite/ChangeLog:

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

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

This adjusts:

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

to make them buildable as C++ programs.

gdb/testsuite/ChangeLog:

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

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

Adjust gdb.base/charset.{c,exp} so that the testcase works when
compiled as a C++ program.

wchar_t is built-in in C++, so don't make a phony typedef.

The "print /d" is so that we also get "1" instead of "true" in C++
mode.

gdb/testsuite/ChangeLog:

* gdb.base/charset.c [__cplusplus] (wchar_t, char16_t, char32_t):
Don't define.
(utf_32_string): Compile for both C and C++.
* gdb.base/charset.exp: Use "print /d".

4 years agogdb.base/watchpoint.{c,exp}
Pedro Alves [Thu, 17 Sep 2020 22:33:41 +0000 (23:33 +0100)]
gdb.base/watchpoint.{c,exp}

Adjust gdb.base/watchpoint.c so that it can be built as a C++ program.

Fixes:
gdb compile failed, src/gdb/testsuite/gdb.base/watchpoint.c:33:16: error: initializer-string for array of chars is too long [-fpermissive]
   33 | char buf[30] = "testtesttesttesttesttesttestte";
      |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/gdb/testsuite/gdb.base/watchpoint.c:62:14: error: expected unqualified-id before 'nullptr'
   62 | struct foo5 *nullptr;
      |              ^~~~~~~

gdb/testsuite/ChangeLog:

* gdb.base/watchpoint.c (buf): Make it 31 bytes.
(nullptr): Rename to ...
(null_ptr): ... this.
* gdb.base/watchpoint.exp: Adjust to rename.

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

Adjust gdb.base/printcmds.c to make it buildable as a C++ program.

gdb/testsuite/ChangeLog:

* gdb.base/printcmds.c (three, flag_enum_without_zero)
(three_not_flag): Add casts.

4 years agogdb.base/examine-backward.exp C++ify and Clang
Pedro Alves [Thu, 17 Sep 2020 22:33:40 +0000 (23:33 +0100)]
gdb.base/examine-backward.exp C++ify and Clang

Adjust gdb.base/examine-backward.exp to let the testcase build and run
as a C++ program, built with either G++ or Clang++.

The change to use unsigned char instead of plain char is to avoid
narrowing warnings:

  gdb compile failed, src/gdb/testsuite/gdb.base/examine-backward.c:55:1: error: narrowing conversion of '227' from 'int' to 'char' [-Wnarrowing]
     55 | };
| ^

gdb/testsuite/ChangeLog:

* gdb.base/examine-backward.c (Barrier, TestStrings): Now unsigned
char array.
(main): Add references to Barrier, TestStrings, TestStringsH and
TestStringsW.
* gdb.base/examine-backward.exp: Issue "set print asm-demangle on"
and expect a full prototype in C++.

4 years agogdb.base/nested-addr.{c,exp} C++ify
Pedro Alves [Thu, 17 Sep 2020 22:33:40 +0000 (23:33 +0100)]
gdb.base/nested-addr.{c,exp} C++ify

Adjust gdb.base/nested-addr.exp to let the testcase build and run as a
C++ program.  "print /d" is used so we get "= 1" instead of "= true"
in C++ mode.

gdb/testsuite/ChangeLog:

* gdb.base/nested-addr.c (main): Add cast.
* gdb.base/nested-addr.exp: Use "print /d".

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

Some adjustments to make gdb.base/break.exp work when compiled as a
C++ program.  Passes cleanly with Clang++, but not with G++.  The
latter puts a breakpoint at an unexpected line in one case.  It seems
like a bug that gcc and g++ behave differently here.

gdb/testsuite/ChangeLog:

* gdb.base/break.exp (func): New.  Use it throughout when
expecting a function name.

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

This makes the testcase work when compiled with C++ compiler.

gdb/testsuite/ChangeLog:

* gdb.base/display.exp: Issue "set print asm-demangle on".

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

This makes the testcase work when compiled with C++ compiler.

We need #include <string.h> for memset.

gdb/testsuite/ChangeLog:

* gdb.base/find.c: Include <string.h>.
(init_bufs): Add cast.
* gdb.base/find.exp: Issue "set print asm-demangle on".

4 years agoChange management of tdesc_arch_data
Tom Tromey [Thu, 17 Sep 2020 20:11:38 +0000 (14:11 -0600)]
Change management of tdesc_arch_data

While working on something else, I noticed that tdesc_data_cleanup
took a void* parameter.  Looking more into this, I found that
tdesc_use_registers expected a transfer of ownership.

I think it's better to express this sort of thing via the type system,
when possible.  This patch changes tdesc_data_alloc to return a unique
pointer, changes tdesc_use_registers to accept an rvalue reference,
and then adapts all the users.

Note that a deleter structure is introduced to avoid having to move
tdesc_arch_data to the header file.

2020-09-17  Tom Tromey  <tromey@adacore.com>

* tic6x-tdep.c (tic6x_gdbarch_init): Update.
* target-descriptions.h (struct tdesc_arch_data_deleter): New.
(tdesc_arch_data_up): New typedef.
(tdesc_use_registers, tdesc_data_alloc): Update.
(tdesc_data_cleanup): Don't declare.
* target-descriptions.c (tdesc_data_alloc): Return a
tdesc_arch_data_up.
(tdesc_arch_data_deleter::operator()): Rename from
tdesc_data_cleanup.  Change argument type.
(tdesc_use_registers): Change early_data to an rvalue reference.
(tdesc_use_registers): Don't use delete.
* sparc-tdep.c (sparc32_gdbarch_init): Update.
* s390-tdep.c (s390_gdbarch_init): Update.
* rx-tdep.c (rx_gdbarch_init): Update.
* rs6000-tdep.c (rs6000_gdbarch_init): Update.
* riscv-tdep.c (riscv_gdbarch_init): Update.
* or1k-tdep.c (or1k_gdbarch_init): Update.
* nios2-tdep.c (nios2_gdbarch_init): Update.
* nds32-tdep.c (nds32_gdbarch_init): Update.
* mips-tdep.c (mips_gdbarch_init): Update.
* microblaze-tdep.c (microblaze_gdbarch_init): Update.
* m68k-tdep.c (m68k_gdbarch_init): Update.
* i386-tdep.c (i386_gdbarch_init): Update.
* arm-tdep.c (arm_gdbarch_init): Update.
* arc-tdep.c (arc_tdesc_init): Update.
(arc_gdbarch_init): Update.
* aarch64-tdep.c (aarch64_gdbarch_init): Update.

4 years agoFix ctrl-c when debugging WOW64 processes
Hannes Domani [Thu, 17 Sep 2020 17:10:16 +0000 (19:10 +0200)]
Fix ctrl-c when debugging WOW64 processes

DebugBreakProcess starts a new thread in the target process with the
entry point DbgUiRemoteBreakin, where an int3 triggers a breakpoint
exception for gdb.

But this uses DbgUiRemoteBreakin of the 64bit ntdll.dll even for
WOW64 processes.
It stops in 64bit code, Wow64GetThreadContext reports a wrong pc without
the int3, and gdb lets the target process continue.

So this uses DbgUiRemoteBreakin of the 32bit ntdll.dll as the thread
entry point for WOW64 processes instead.

gdb/ChangeLog:

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

* windows-nat.c (ctrl_c_handler): Use 32bit DbgUiRemoteBreakin
for WOW64 processes.

4 years agoUse htab_up in dwarf2/read.c
Tom Tromey [Thu, 17 Sep 2020 17:47:50 +0000 (11:47 -0600)]
Use htab_up in dwarf2/read.c

This changes dwarf2/read.c to use htab_up rather than explicit calls
to htab_delete.

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

* dwarf2/read.c (compute_compunit_symtab_includes): Use htab_up.

4 years agoUse htab_up in type copying
Tom Tromey [Thu, 17 Sep 2020 17:47:50 +0000 (11:47 -0600)]
Use htab_up in type copying

This changes create_copied_types_hash to return an htab_up, then
modifies the callers to avoid explicit use of htab_delete.

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

* value.c (preserve_values): Update.
* python/py-type.c (save_objfile_types): Update.
* guile/scm-type.c (save_objfile_types): Update.
* gdbtypes.h (create_copied_types_hash): Return htab_up.
* gdbtypes.c (create_copied_types_hash): Return htab_up.
* compile/compile-object-run.c (compile_object_run): Update.

4 years agoUse htab_up in typedef_hash_table
Tom Tromey [Thu, 17 Sep 2020 17:47:50 +0000 (11:47 -0600)]
Use htab_up in typedef_hash_table

This changes typedef_hash_table to use htab_up rather than explicit
calls to htab_delete.

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

* typeprint.h (class typedef_hash_table) <~typedef_hash_table>:
Remove.
<m_table>: Now htab_up.
* typeprint.c (typedef_hash_table::recursively_update)
(typedef_hash_table::add_template_parameters)
(typedef_hash_table::typedef_hash_table): Update.
(typedef_hash_table::~typedef_hash_table): Remove.
(typedef_hash_table::typedef_hash_table)
(typedef_hash_table::find_global_typedef)
(typedef_hash_table::find_typedef): Update.

4 years agoUse htab_up in target-descriptions.c
Tom Tromey [Thu, 17 Sep 2020 17:47:50 +0000 (11:47 -0600)]
Use htab_up in target-descriptions.c

This changes target-descriptions.c to use htab_up rather than explicit
calls to htab_delete.

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

* target-descriptions.c (tdesc_use_registers): Use htab_up.

4 years agoUse htab_up in linespec.c
Tom Tromey [Thu, 17 Sep 2020 17:47:50 +0000 (11:47 -0600)]
Use htab_up in linespec.c

This changes linespec.c to use htab_up rather than explicit calls to
htab_delete.  Note that a use still exists in this file, because
linespec_state hasn't been converted to have a real destructor.

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

* linespec.c (class decode_compound_collector)
<~decode_compound_collector>: Remove.
<m_unique_syms>: Now htab_up.
(decode_compound_collector::operator ()): Update.
(class symtab_collector) <~symtab_collector>: Remove.
<m_symtab_table>: Now htab_up.
(symtab_collector::operator ()): Update.

4 years agoUse htab_up in filename_seen_cache
Tom Tromey [Thu, 17 Sep 2020 17:47:50 +0000 (11:47 -0600)]
Use htab_up in filename_seen_cache

This changes filename_seen_cache to use htab_up, rather than explicit
calls to htab_delete.

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

* filename-seen-cache.c (filename_seen_cache::filename_seen_cache)
(filename_seen_cache::clear): Update.
(~filename_seen_cache): Remove.
(filename_seen_cache::seen): Update.
* filename-seen-cache.h (class filename_seen_cache) <m_tab>: Now
htab_up.
<~filename_seen_cache>: Remove.
<traverse>: Update.

4 years agoUse htab_up in completion_tracker
Tom Tromey [Thu, 17 Sep 2020 17:47:50 +0000 (11:47 -0600)]
Use htab_up in completion_tracker

This changes completion_tracker to use htab_up, rather than explicit
calls to htab_delete.

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

* completer.c (completion_tracker::discard_completions)
(completion_tracker::~completion_tracker)
(completion_tracker::maybe_add_completion)
(completion_tracker::remove_completion)
(completion_tracker::recompute_lowest_common_denominator)
(completion_tracker::build_completion_result): Update.
* completer.h (class completion_tracker) <have_completions>:
Update.
<m_entries_hash>: Now htab_up.

4 years agoUse htab_up in breakpoint.c
Tom Tromey [Thu, 17 Sep 2020 17:47:50 +0000 (11:47 -0600)]
Use htab_up in breakpoint.c

This changes breakpoint.c to use htab_up rather than an explicit
htab_delete.  This simplifies the code somewhat.

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

* breakpoint.c (ambiguous_names_p): Use htab_up.

4 years agoUse htab_up in auto-load.c
Tom Tromey [Thu, 17 Sep 2020 17:47:50 +0000 (11:47 -0600)]
Use htab_up in auto-load.c

This changes auto-load.c to use htab_up, rather than manually calling
htab_delete.

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

* auto-load.c (struct auto_load_pspace_info)
<~auto_load_pspace_info, auto_load_pspace_info>: Remove.
<loaded_script_files, loaded_script_texts>: Change type to
htab_up.
(~auto_load_pspace_info) Remove.
(init_loaded_scripts_info, maybe_add_script_file)
(maybe_add_script_text, auto_load_info_scripts): Update.

4 years agoMake c-exp.y:name_obstack static
Tom Tromey [Thu, 17 Sep 2020 14:06:01 +0000 (08:06 -0600)]
Make c-exp.y:name_obstack static

c-exp.y:name_obstack is not static, but should be.  This patch makes
the change.  Tested by rebuilding.

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

* c-exp.y (name_obstack): Now static.

4 years agoSkip IFUNC relocations in debug sections ignored by ld.so. Fixes some ld test failur...
Mikael Pettersson [Thu, 17 Sep 2020 09:45:39 +0000 (10:45 +0100)]
Skip IFUNC relocations in debug sections ignored by ld.so.  Fixes some ld test failures on sparc-linux-gnu.

PR ld/18808
* elfxx-sparc.c (_bfd_sparc_elf_relocate_section): Skip IFUNC
relocations in debug sections, change abort to _bfd_error_handler.

4 years agogdb/riscv: fix decode of c.sdsp instruction
Chungyi Chi [Thu, 17 Sep 2020 08:45:50 +0000 (09:45 +0100)]
gdb/riscv: fix decode of c.sdsp instruction

The decode of c.sdsp was incorrectly claiming to be a 4-byte store
instead of an 8-byte store.

gdb/ChangeLog:

* riscv-tdep.c (riscv-insn::decode): Fix recorded insn type.

4 years agoTidy gas i386.exp
Alan Modra [Thu, 17 Sep 2020 08:02:59 +0000 (17:32 +0930)]
Tidy gas i386.exp

Possibly a quirk of my version of tcl, but I see "nm-new --help" being
run on non-x86 targets.

* testsuite/gas/i386/i386.exp: Return early if not x86.

4 years agoopcodes/csky: return the default disassembler when there is no bfd
Andrew Burgess [Wed, 16 Sep 2020 09:12:39 +0000 (10:12 +0100)]
opcodes/csky: return the default disassembler when there is no bfd

The disassembler function should return a valid disassembler function
even when there is no BFD present.  This is implied (I believe) by the
comment in dis-asm.h which says the BFD may be NULL.  Further, it
makes sense when considering that the disassembler is used in GDB, and
GDB may connect to a target and perform debugging even without a BFD
being supplied.

This commit makes the csky_get_disassembler function return the
default disassembler configuration when no bfd is supplied, this is
the same default configuration as is used when a BFD is supplied, but
the BFD has no attributes section.

Before the change configuring GDB with --enable-targets=all and
running the tests gdb.base/all-architectures-2.exp results in many
errors, but after this change there are no failures.

opcodes/ChangeLog:

* csky-dis.c (csky_get_disassembler): Don't return NULL when there
is no BFD.

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

4 years agogdb: use bool in the solib catchpoint area
Simon Marchi [Wed, 16 Sep 2020 21:26:30 +0000 (17:26 -0400)]
gdb: use bool in the solib catchpoint area

Use bool instead of int in struct solib_catchpoint and in init_catchpoint &
related functions.

gdb/ChangeLog:

* breakpoint.h (init_catchpoint): Change int parameter to bool.
(add_solib_catchpoint): Likewise.
* breakpoint.c (struct solib_catchpoint) <is_load>: Change type
to bool.
(add_solib_catchpoint): Change int parameter/variable to bool.
(catch_load_or_unload): Likewise.
(init_catchpoint): Likewise.
(create_fork_vfork_event_catchpoint): Likewise.
(catch_fork_command_1): Likewise.
(catch_exec_command_1): Likewise.

Change-Id: I1faf4506e9109f3ccdd7229ba766dc7d77aa7aa0

4 years agogdb: update instance_flags field name in gdb-gdb.py.in
Simon Marchi [Wed, 16 Sep 2020 20:43:39 +0000 (16:43 -0400)]
gdb: update instance_flags field name in gdb-gdb.py.in

Commit 314ad88df63c ("Use type_instance_flags more throughout") changed
the name of field type::instance_flags to type::m_instance_flags.  It
however missed changing it in the gdb-gdb.py.in file, which results in
this when trying to use the pretty-printer:

    (top-gdb) p *val.type
    Traceback (most recent call last):
      File "/home/smarchi/build/binutils-gdb/gdb/gdb-gdb.py", line 116, in to_string
        % TypeFlagsPrinter(self.val['instance_flags']))
      File "/home/smarchi/build/binutils-gdb/gdb/gdb-gdb.py", line 76, in __str__
        flag_list = [flag.short_name for flag in TYPE_FLAGS
      File "/home/smarchi/build/binutils-gdb/gdb/gdb-gdb.py", line 77, in <listcomp>
        if self.val & flag.value]
    gdb.error: Argument to arithmetic operation not a number or boolean.
    $7 =

This patch fixes it.

gdb/ChangeLog:

* gdb-gdb.py.in (class StructTypePrettyPrinter) <to_string>:
Change instance_flags to m_instance_flags.

Change-Id: Ib5e03c08fe41ca11cd71998f2b1c58052879ce95

4 years agoMatch demangled name in "skip"
Tom Tromey [Wed, 16 Sep 2020 15:49:36 +0000 (09:49 -0600)]
Match demangled name in "skip"

PR gdb/26598 notes that, before commit bcfe6157ca28 ("Use the linkage
name if it exists"), the "skip" command would match the demangled name
of a symbol, but now only matches the linkage name.

This patch fixes this regression.  I looked at all calls to
function_name_is_marked_for_skip, and only one used the linkage name.

2020-09-16  Tom Tromey  <tromey@adacore.com>

PR gdb/26598:
* infrun.c (fill_in_stop_func): Use find_pc_partial_function_sym.

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

PR gdb/26598:
* gdb.base/skipcxx.exp: New file.
* gdb.base/skipcxx.cc: New file.

4 years agoAssume FreeBSD kernels always report exec events.
John Baldwin [Wed, 16 Sep 2020 18:40:05 +0000 (11:40 -0700)]
Assume FreeBSD kernels always report exec events.

FreeBSD kernels have reported exec events via the PL_FLAG_EXEC flag
since 8.2 release.  The most recent release that did not support this
flag is 7.4 released in November of 2011.

Note that the FreeBSD native target already assumed that PL_FLAG_SCE
and PL_FLAG_SCX were always supported on systems supporting
PT_LWPINFO, but those flags were added at the same time as
PL_FLAG_EXEC.  Building the native target on a system without
PL_FLAG_EXEC would have failed to build before this change already as
a result.

gdb/ChangeLog:

* fbsd-nat.c (fbsd_nat_target::wait): Always check for
PL_FLAG_EXEC.
(fbsd_nat_target::insert_exec_catchpoint)
(fbsd_nat_target::remove_exec_catchpoint): Always define.
* fbsd-nat.h (fbsd_nat_target::insert_exec_catchpoint)
(fbsd_nat_target::remove_exec_catchpoint): Always declare.

4 years agoRequire kinfo_get_file and kinfo_get_vmmap for FreeBSD hosts.
John Baldwin [Wed, 16 Sep 2020 18:40:05 +0000 (11:40 -0700)]
Require kinfo_get_file and kinfo_get_vmmap for FreeBSD hosts.

FreeBSD systems have provided these functions in libutil since 7.1
release.  The most recent release without support is 6.4 released in
November of 2008.

This also requires libutil-freebsd on GNU/kFreeBSD systems.  I assume
that those systems have supported kinfo_get_file and kinfo_get_vmmap
over a similar timeframe.

gdb/ChangeLog:

* configure.ac: Remove check for kinfo_getvmmap().
* configure, config.in: Regenerate.
* fbsd-nat.c (fbsd_read_mapping): Remove
(fbsd_nat_target::find_memory_regions): Remove the procfs version.
(fbsd_nat_target::info_proc): Assume kinfo_getfile() and
kinfo_get_vmmap() are always present.

gdbsupport/ChangeLog:

* common.m4 (GDB_AC_COMMON): Refactor checks for kinfo_getfile().
* configure, config.in: Regenerate.

4 years agoAssume FreeBSD hosts include support for fetching signal information.
John Baldwin [Wed, 16 Sep 2020 18:40:05 +0000 (11:40 -0700)]
Assume FreeBSD hosts include support for fetching signal information.

The current layout of siginfo_t and support for fetching it has been
included in FreeBSD kernels since 7.0 release.  The most recent
release without support is 6.4 released in November of 2008.

gdb/ChangeLog:

* fbsd-nat.c: Always include support for
TARGET_OBJECT_SIGNAL_INFO.

4 years agoAssume KERN_PROC_PATHNAME is present on FreeBSD hosts.
John Baldwin [Wed, 16 Sep 2020 18:40:05 +0000 (11:40 -0700)]
Assume KERN_PROC_PATHNAME is present on FreeBSD hosts.

FreeBSD kernels have included this sysctl since 6.0 release.  The most
recent release without support is 5.5 which was released in May of
2006.

Both the sysctl and the /proc/<pid>/exe file call the same function in
the kernel to obtain the path (vn_fullpath).  If the sysctl fails, the
readlink call will also fail, so there is no need to keep the readlink
fallback.

gdb/ChangeLog:

* fbsd-nat.c (fbsd_nat_target::pid_to_exec_file): Always use
sysctl and remove procfs fallback.

4 years agoAssume that PT_LWPINFO is always defined on FreeBSD hosts.
John Baldwin [Wed, 16 Sep 2020 18:40:04 +0000 (11:40 -0700)]
Assume that PT_LWPINFO is always defined on FreeBSD hosts.

FreeBSD kernels have included support for this since 5.0 release.
The most recent release without support is 4.11 which was released
in January of 2005.

gdb/ChangeLog:

* fbsd-nat.c: Assume PT_LWPINFO is always defined.
* fbsd-nat.h: Likewise.

4 years ago[gdb/testsuite] Fix gdb.dlang/watch-loc.exp on ppc64
Tom de Vries [Wed, 16 Sep 2020 16:04:37 +0000 (18:04 +0200)]
[gdb/testsuite] Fix gdb.dlang/watch-loc.exp on ppc64

On ppc64, we run into:
...
/tmp/ccKXURmw.s: Assembler messages:^M
/tmp/ccKXURmw.s:99: Error: can't resolve \
  `_Dmain_end' {.text section} - `_Dmain' {.opd section}^M
compiler exited with status 1
...

The unresolvable entity comes from the .debug_aranges section hardcoded in
watch-loc.c:
...
"      .4byte  _Dmain \n"      // Address
"      .4byte  _Dmain_end - _Dmain \n" // Length
...
where _Dmain is the function label for function _Dmain, and _Dmain_end is a
label after function _Dmain:
...
int _Dmain (void)
{
  asm ("_Dmain_label: .globl _Dmain_label");
  return 0;
}

asm ("_Dmain_end: .globl _Dmain_end");
...

The problem is that the two labels are not in the same section, because _Dmain
ends up in the .opd section, which "contains the official procedure
descriptors.  A pointer to a function shall reference a procedure descriptor in
this section."

Fix this by using function_range instead to get the length.

Also, fix the address part to not use _Dmain, but instead use the function
start as returned by function_range.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

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

PR testsuite/26617
* gdb.dlang/watch-loc.c: Only add .debug_aranges if
        WITH_DEBUG_SECTIONS is defined.
(xstr, str): New macro.
(.debug_aranges): Use DMAIN_START_0/1/2 and DMAIN_LENGTH
to get start and size of _Dmain.
* gdb.dlang/watch-loc.exp: Pass DMAIN_START_0/1/2 and DMAIN_LENGTH
using additional_flags.

4 years agoAdd -Av9 to AFLAGS_PIC and AFLAGS_PIE in the ld test suite on SPARC.
Mikael Pettersson [Wed, 16 Sep 2020 15:20:51 +0000 (16:20 +0100)]
Add -Av9 to AFLAGS_PIC and AFLAGS_PIE in the ld test suite on SPARC.

* testsuite/ld-elf/shared.exp: Add -Av9 to AFLAGS_PIE on sparc.
* testsuite/ld-elf/tls.exp: Add -Av9 to AFLAGS_PIC on sparc.

4 years agoOops - failed to commit change to verilog.c. Trying again.
Nick Clifton [Wed, 16 Sep 2020 15:19:53 +0000 (16:19 +0100)]
Oops - failed to commit change to verilog.c.  Trying again.

* verilog.c (verilog_write_address): Properly handle 64-bit
addresses to avoid truncation of the high part.

4 years agogdb/breakpoint: make a copy of the "commands" command's argument
Tankut Baris Aktemur [Fri, 11 Sep 2020 13:04:01 +0000 (15:04 +0200)]
gdb/breakpoint: make a copy of the "commands" command's argument

When GDB reads commands from the input, its internal buffer is re-used
for each line.  This is usually just fine because commands are
executed in order; by the time we read the next line, we are already
done with the current line.  However, a problematic case is breakpoint
commands that are input from a script.  The header (e.g. commands 1 2)
is overwritten with the next line before the breakpoint numbers are
processed completely.

For example, suppose we have the following script:

  break main
  break main
  commands 1 2
    print 100123
  end

and source this script:

  (gdb) source script.gdb
  Breakpoint 1 at 0x1245: file main.cpp, line 27.
  Breakpoint 2 at 0x1245: file main.cpp, line 27.
  No breakpoint number 123.

Note the "No breakpoint number 123." error message.  This happens
because GDB first reads "commands 1 2" into its internal buffer

  buffer -> "commands 1 2"

and then starts parsing the breakpoint numbers.  After parsing the first
token, the "next token" pointer is as below:

  buffer -> "commands 1 2"
  next-token -----------^

So, if we continue parsing, we would tokenize "2" correctly.  However,
before parsing the next number, GDB reads the commands to attach them
to breakpoint 1.  Reading the commands causes the buffer to be
overwritten:

  buffer -> "  print 100123"
  next-token -----------^

So, the next time we parse the breakpoint number, we read "123".

To fix, simply create a copy of the arguments of the header.

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

* breakpoint.c (commands_command_1): Make a copy of the 'arg'
argument.

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

* gdb.base/bp-cmds-sourced-script.c: New file.
* gdb.base/bp-cmds-sourced-script.exp: New test.
* gdb.base/bp-cmds-sourced-script.gdb: New file.

4 years agoelf/x86-64: Adjust relocation for PE/x86-64 inputs
H.J. Lu [Wed, 16 Sep 2020 14:11:16 +0000 (07:11 -0700)]
elf/x86-64: Adjust relocation for PE/x86-64 inputs

PE linker calls _bfd_relocate_contents to resolve relocation, instead of
bfd_perform_relocation.  But ELF linker calls bfd_perform_relocation, not
_bfd_relocate_contents.  When linking PE/x86-64 inputs to generate ELF
output, we need to adjust PE/x86-64 relocations in bfd_perform_relocation.

Enable PE/x86-64 in bfd together with PEI/x86-64.  Update run_ld_link_tests
to handle bzip2 binary inputs.

bfd/

PR ld/26583
* config.bfd (targ64_selvecs, targ_selvecs): Add x86_64_pe_vec
to x86_64_pei_vec.
* reloc.c: Include "coff/internal.h".
(bfd_perform_relocation): Adjust relocation for PE/x86-64 inputs.

ld/

PR ld/26583
* testsuite/ld-x86-64/pe-x86-64-1.od: New file.
* testsuite/ld-x86-64/pe-x86-64-1a.obj.bz2: Likewise.
* testsuite/ld-x86-64/pe-x86-64-1b.obj.bz2: Likewise.
* testsuite/ld-x86-64/pe-x86-64-1c.obj.bz2: Likewise.
* testsuite/ld-x86-64/pe-x86-64-2.od: Likewise.
* testsuite/ld-x86-64/pe-x86-64-2a.obj.bz2: Likewise.
* testsuite/ld-x86-64/pe-x86-64-2b.obj.bz2: Likewise.
* testsuite/ld-x86-64/pe-x86-64-2c.obj.bz2: Likewise.
* testsuite/ld-x86-64/pe-x86-64-3.od: Likewise.
* testsuite/ld-x86-64/pe-x86-64-3a.obj.bz2: Likewise.
* testsuite/ld-x86-64/pe-x86-64-3b.obj.bz2: Likewise.
* testsuite/ld-x86-64/pe-x86-64-3c.obj.bz2: Likewise.
* testsuite/ld-x86-64/pe-x86-64-3d.obj.bz2: Likewise.
* testsuite/ld-x86-64/pe-x86-64-4.od: Likewise.
* testsuite/ld-x86-64/pe-x86-64-4a.obj.bz2: Likewise.
* testsuite/ld-x86-64/pe-x86-64-4b.obj.bz2: Likewise.
* testsuite/ld-x86-64/pe-x86-64-4c.obj.bz2: Likewise.
* testsuite/ld-x86-64/pe-x86-64-4d.obj.bz2: Likewise.
* testsuite/ld-x86-64/pe-x86-64.exp: Likewise.
* testsuite/lib/ld-lib.exp (run_ld_link_tests): Handle bz2 binary
inputs.

4 years ago[gdb/testsuite] Detect gdb prompt after monitor exit
Tom de Vries [Wed, 16 Sep 2020 12:53:26 +0000 (14:53 +0200)]
[gdb/testsuite] Detect gdb prompt after monitor exit

With this gdbserver-support.exp patch:
...
@@ -451,8 +451,10 @@ proc gdbserver_exit { is_mi } {
      # We use expect rather than gdb_expect because
      # we want to suppress printing exception messages, otherwise,
      # remote_expect, invoked by gdb_expect, prints the exceptions.
+     set have_prompt 0
      expect {
  -i "$gdb_spawn_id" -re "$gdb_prompt $" {
+     set have_prompt 1
      exp_continue
  }
  -i "$server_spawn_id" eof {
@@ -463,6 +465,7 @@ proc gdbserver_exit { is_mi } {
                    warning "Timed out waiting for EOF in server after $monitor_exit"
                }
      }
+     gdb_assert {$have_prompt}
  }
     }
     close_gdbserver
...
and with this in parallel:
...
$ stress -c 5
...
we run into this and similar FAILs:
...
FAIL: gdb.multi/multi-target.exp: continue: non-stop=on: $have_prompt
...

In more detail:
...
(gdb) PASS: gdb.multi/multi-target.exp: continue: non-stop=on: inferior 5
Remote debugging from host ::1, port 40712^M
Process build/gdb/testsuite/outputs/gdb.multi/multi-target/multi-target \
  created; pid = 11098^M
monitor exit^M
Killing process(es): 11098^M
FAIL: gdb.multi/multi-target.exp: continue: non-stop=on: $have_prompt
spawn build/gdb/testsuite/../../gdb/gdb -nw -nx -data-directory \
  build/gdb/testsuite/../data-directory^M
...

After issuing a "monitor exit" command, we should always get a prompt back, so
check for that.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

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

* lib/gdbserver-support.exp (gdbserver_exit): Make sure we
get the gdb prompt after issuing "monitor exit".

4 years agobfd: verilog hex dump backend should handle 64-bit addresses
Anatoly Parshintsev [Wed, 16 Sep 2020 12:17:24 +0000 (13:17 +0100)]
bfd: verilog hex dump backend should handle 64-bit addresses

       * verilog.c (verilog_write_address): Properly handle 64-bit
addresses to avoid truncation of the high part.

4 years ago[gdb/testsuite] Catch condition evaluation errors in gdb_assert
Tom de Vries [Wed, 16 Sep 2020 11:27:32 +0000 (13:27 +0200)]
[gdb/testsuite] Catch condition evaluation errors in gdb_assert

When running test-case gdb.base/watchpoint-stops-at-right-insn.exp, we may run
into a tcl error, which can be reproduced reliably using this trigger patch:
...
+       set hw_watch_pc ""
        gdb_assert {$sw_watch_pc == $hw_watch_pc} \
  "hw watchpoint stops at right instruction"
...
such that we have:
...
ERROR: tcl error sourcing watchpoint-stops-at-right-insn.exp.
ERROR: missing operand at _@_
in expression "0x4004b7 == _@_"
    (parsing expression "0x4004b7 == ")
    invoked from within
"expr $sw_watch_pc == $hw_watch_pc"
    ("uplevel" body line 1)
    invoked from within
"uplevel 1 expr $condition"
    (procedure "gdb_assert" line 6)
    invoked from within
"gdb_assert {$sw_watch_pc == $hw_watch_pc} \
  "hw watchpoint stops at right instruction""
...

A similar problem was fixed in commit 5f0e2eb79e "GDB/testsuite: Fix a
catastrophic step-over-no-symbols.exp failure", by making the assert condition
more robust:
...
-    gdb_assert {$before_addr != $after_addr} "advanced"
+    gdb_assert {{[string is integer -strict $before_addr] \
+                && [string is integer -strict $after_addr] \
+                && $before_addr != $after_addr}} "advanced"
...

Fix this instead in gdb_assert, by catching errors while evaluating the assert
condition.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

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

PR testsuite/26624
* lib/gdb.exp (gdb_assert): Catch errors in condition evaluation.

4 years agogdb: Remove language_data struct
Andrew Burgess [Tue, 4 Aug 2020 16:13:40 +0000 (17:13 +0100)]
gdb: Remove language_data struct

The language_data type, from which language_defn inherits, is now
empty, and this commit removes it.

Each language is updated to no longer create and use a language_data
struct.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (ada_language_data): Delete.
(ada_language): Remove references to ada_language_data.
* c-lang.c (c_language_data): Delete.
(c_language): Remove references to c_language_data.
(cplus_language_data): Delete.
(cplus_language): Remove references to cplus_language_data.
(asm_language_data): Delete.
(asm_language): Remove references to asm_language_data.
(minimal_language_data): Delete.
(minimal_language): Remove references to minimal_language_data.
* d-lang.c (d_language_data): Delete.
(d_language): Remove references to d_language_data.
* f-lang.c (f_language_data): Delete.
(f_language): Remove references to f_language_data.
* go-lang.c (go_language_data): Delete.
(go_language): Remove references to go_language_data.
* language.c (unknown_language_data): Delete.
(unknown_language): Remove references to unknown_language_data.
(auto_language_data): Delete.
(auto_language): Remove references to auto_language_data.
* language.h (language_data): Delete struct.
(language_defn): No longer inherit from language_data.
* m2-lang.c (m2_language_data): Delete.
(m2_language): Remove references to m2_language_data.
* objc-lang.c (objc_language_data): Delete.
(objc_language): Remove references to objc_language_data.
* opencl-lang.c (opencl_language_data): Delete.
(opencl_language): Remove references to opencl_language_data.
* p-lang.c (pascal_language_data): Delete.
(pascal_language): Remove references to pascal_language_data.
* rust-lang.c (rust_language_data): Delete.
(rust_language): Remove references to rust_language_data.

4 years agogdb: Convert language_data::la_op_print_tab to a method
Andrew Burgess [Tue, 4 Aug 2020 16:07:59 +0000 (17:07 +0100)]
gdb: Convert language_data::la_op_print_tab to a method

Convert language_data::la_op_print_tab member variable to a virtual
method language_defn::opcode_print_table.  I changed the name in order
to make it clearer (I hope) what the method does.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (ada_language_data): Remove la_op_print_tab
initializer.
(ada_language::opcode_print_table): New member function.
* c-lang.c (c_language_data): Remove la_op_print_tab initializer.
(c_language::opcode_print_table): New member function.
(cplus_language_data): Remove la_op_print_tab initializer.
(cplus_language::opcode_print_table): New member function.
(asm_language_data): Remove la_op_print_tab initializer.
(asm_language::opcode_print_table): New member function.
(minimal_language_data): Remove la_op_print_tab initializer.
(minimal_language::opcode_print_table): New member function.
* d-lang.c (d_language_data): Remove la_op_print_tab initializer.
(d_language::opcode_print_table): New member function.
* expprint.c (print_subexp_standard): Update call to
opcode_print_table.
(op_string): Likewise.
* f-lang.c (f_language_data): Remove la_op_print_tab initializer.
(f_language::opcode_print_table): New member function.
* go-lang.c (go_language_data): Remove la_op_print_tab
initializer.
(go_language::opcode_print_table): New member function.
* language.c (unknown_language_data): Remove la_op_print_tab
initializer.
(unknown_language::opcode_print_table): New member function.
(auto_language_data): Remove la_op_print_tab initializer.
(auto_language::opcode_print_table): New member function.
* language.h (language_data): Remove la_op_print_tab field.
(language_defn::opcode_print_table): Declare new member function.
* m2-lang.c (m2_language_data): Remove la_op_print_tab
initializer.
(m2_language::opcode_print_table): New member function.
* objc-lang.c (objc_language_data): Remove la_op_print_tab
initializer.
(objc_language::opcode_print_table): New member function.
* opencl-lang.c (opencl_language_data): Remove la_op_print_tab
initializer.
(opencl_language::opcode_print_table): New member function.
* p-lang.c (pascal_language_data): Remove la_op_print_tab
initializer.
(pascal_language::opcode_print_table): New member function.
* rust-lang.c (rust_language_data): Remove la_op_print_tab
initializer.
(rust_language::opcode_print_table): New member function.

4 years agogdb: Convert language_data::la_exp_desc to a method
Andrew Burgess [Tue, 4 Aug 2020 15:31:56 +0000 (16:31 +0100)]
gdb: Convert language_data::la_exp_desc to a method

Convert language_data::la_exp_desc member variable to a virtual
method language_defn::expression_ops.  The change of names brings this
method more into line with the existing varobj_ops method, that also
returns a table of function pointers.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (ada_language_data): Remove la_exp_desc initializer.
(ada_language::expression_ops): New member function.
* c-lang.c (c_language_data): Remove la_exp_desc initializer.
(c_language::expression_ops): New member function.
(cplus_language_data): Remove la_exp_desc initializer.
(cplus_language::expression_ops): New member function.
(asm_language_data): Remove la_exp_desc initializer.
(asm_language::expression_ops): New member function.
(minimal_language_data): Remove la_exp_desc initializer.
(minimal_language::expression_ops): New member function.
* d-lang.c (d_language_data): Remove la_exp_desc initializer.
(d_language::expression_ops): New member function.
* eval.c (evaluate_subexp): Update call to expression_ops.
* expprint.c (print_subexp): Likewise.
(op_name): Likewise.
(dump_subexp_body): Likewise.
* f-lang.c (f_language_data): Remove la_exp_desc initializer.
(f_language::expression_ops): New member function.
* go-lang.c (go_language_data): Remove la_exp_desc initializer.
(go_language::expression_ops): New member function.
* language.c (language_defn::expression_ops): New function.
(unknown_language_data): Remove la_exp_desc initializer.
(auto_language_data): Likewise.
* language.h (language_data): Remove la_exp_desc field.
(language_defn::expression_ops): Declare new member function.
* m2-lang.c (m2_language_data): Remove la_exp_desc initializer.
(m2_language::expression_ops): New member function.
* objc-lang.c (objc_language_data): Remove la_exp_desc
initializer.
* opencl-lang.c (opencl_language_data): Remove la_exp_desc
initializer.
(opencl_language::expression_ops): New member function.
* p-lang.c (pascal_language_data): Remove la_exp_desc initializer.
* parse.c (operator_length): Update call to expression_ops.
(exp_iterate): Likewise.
* rust-lang.c (rust_language_data): Remove la_exp_desc
initializer.
(ruse_language::expression_ops): New member function.

4 years agogdb: Convert language_data::la_varobj_ops to a method
Andrew Burgess [Tue, 4 Aug 2020 14:59:52 +0000 (15:59 +0100)]
gdb: Convert language_data::la_varobj_ops to a method

Convert language_data::la_varobj_ops member variable to a virtual
method language_defn::varobj_ops.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (ada_language_data): Remove la_varobj_ops
initializer.
(ada_language::varobj_ops): New member function.
* c-lang.c (c_language_data): Remove la_varobj_ops
initializer.
(cplus_language_data): Likewise.
(cplus_language::varobj_ops): New member function.
(asm_language_data): Remove la_varobj_ops initializer.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_language_data): Likewise.
* go-lang.c (go_language_data): Likewise.
* language.c (language_defn::varobj_ops): New function.
(unknown_language_data): Remove la_varobj_ops
initializer.
(auto_language_data): Likewise.
* language.h (language_data): Remove la_varobj_ops field.
(language_defn::varobj_ops): Declare new member function.
* m2-lang.c (m2_language_data): Remove la_varobj_ops initializer.
* objc-lang.c (objc_language_data): Likewise.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_language_data): Likewise.
* varobj.c (varobj_create): Update call to varobj_ops.
* varobj.h (default_varobj_ops): Delete define.

4 years agogdb: Convert language_data::la_macro_expansion to a method
Andrew Burgess [Fri, 31 Jul 2020 14:56:15 +0000 (15:56 +0100)]
gdb: Convert language_data::la_macro_expansion to a method

Convert language_data::la_macro_expansion member variable to a virtual
method language_defn::macro_expansion.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (ada_language_data): Remove la_macro_expansion
initializer.
* c-lang.c (c_language_data): Likewise.
(c_language::macro_expansion): New member function.
(cplus_language_data): Likewise.
(cplus_language::macro_expansion): New member function.
(asm_language_data): Likewise.
(asm_language::macro_expansion): New member function.
(minimal_language_data): Likewise.
(minimal_language::macro_expansion): New member function.
* d-lang.c (d_language_data): Remove la_macro_expansion
initializer.
* f-lang.c (f_language_data): Likewise.
* go-lang.c (go_language_data): Likewise.
* language.c (unknown_language_data): Likewise.
(auto_language_data): Likewise.
* language.h (language_data): Remove la_macro_expansion field.
(language_defn::macro_expansion): New member function.
* m2-lang.c (m2_language_data): Remove la_macro_expansion
initializer.
* objc-lang.c (objc_language_data): Likewise.
(objc_language::macro_expansion): New member function.
* opencl-lang.c (opencl_language_data): Likewise.
(opencl_language::macro_expansion): New member function.
* p-lang.c (pascal_language_data): Remove la_macro_expansion
initializer.
* rust-lang.c (rust_language_data): Likewise.
* symtab.c (default_collect_symbol_completion_matches_break_on):
Update call to macro_expansion.

4 years agogdb: Convert language_data::la_array_ordering to a method
Andrew Burgess [Sun, 12 Jul 2020 15:00:06 +0000 (16:00 +0100)]
gdb: Convert language_data::la_array_ordering to a method

Convert language_data::la_array_ordering member variable to a virtual
method language_defn::array_ordering.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (ada_language_data): Remove la_array_ordering
initializer.
* c-lang.c (c_language_data): Likewise.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* dwarf2/read.c (read_array_order): Update for call to
array_ordering.
* f-lang.c (f_language_data): Remove la_array_ordering
initializer.
(f_language::array_ordering): New member function.
* go-lang.c (go_language_data): Remove la_array_ordering
initializer.
* language.c (unknown_language_data): Likewise.
(auto_language_data): Likewise.
* language.h (language_data): Delete la_array_ordering field.
(language_defn::array_ordering): New member function.
* m2-lang.c (m2_language_data): Remove la_array_ordering
initializer.
* objc-lang.c (objc_language_data): Likewise.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_language_data): Likewise.

4 years agogdb: Convert language_data::la_case_sensitivity to a method
Andrew Burgess [Sun, 12 Jul 2020 14:09:52 +0000 (15:09 +0100)]
gdb: Convert language_data::la_case_sensitivity to a method

Convert language_data::la_case_sensitivity member variable to a virtual
method language_defn::case_sensitivity.

This is mostly straight forward.  The only slight problem is that I
ended up deleting this comment from ada-lang.c:

  /* Yes, Ada is case-insensitive, but that's not quite what this
     means.  */

However, as the comment (which has existed since Ada support was first
added to GDB) doesn't explain _why_ Ada sets case sensitivity to on
despite being a generally case insensitive language, this doesn't
really help me much.

If I understood _why_ the setting doesn't quite mean what it seems to
mean (at least as far as Ada is concerned) then I would extend the
comment on language_defn::case_sensitivity (in language.h) to include
the detail, and note how this impacts Ada.  But as it stands I've just
deleted the comment for now.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (ada_language_data): Remove la_case_sensitivity
initializer.
* c-lang.c (c_language_data): Likewise.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_language_data): Likewise.
(f_language::case_sensitivity): New member function.
* go-lang.c (go_language_data): Remove la_case_sensitivity
initializer.
* language.c (enum case_mode): Moved here from language.h.
(case_mode): Make static.
(show_case_command): Update for case_sensitivity being a method.
(set_case_command): Likewise.
(set_range_case): Likewise.
(unknown_language_data): Remove la_case_sensitivity initializer.
(auto_language_data): Likewise.
* language.h (case_mode): Delete, move enum declaration to
language.c.
(language_data): Delete la_case_sensitivity field.
(language_defn::case_sensitivity): New member function.
* m2-lang.c (m2_language_data): Remove la_case_sensitivity
initializer.
* objc-lang.c (objc_language_data): Likewise.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_language_data): Likewise.

4 years agogdb: Convert language_data::la_range_check to a method
Andrew Burgess [Sun, 12 Jul 2020 09:15:32 +0000 (10:15 +0100)]
gdb: Convert language_data::la_range_check to a method

Convert language_data::la_range_check member variable to a virtual
method language_defn::range_checking_on_by_default.

Where the previous member variable was of type 'enum range_check', the
new member function returns a boolean that selects between range
checking being on or off.  This removes the possibility of a language
having its default be the third enum state, range_check_warn, which
no language currently used.

This all makes sense I think, the language's true/false provides the
default when the global 'set check range' is set to 'auto'.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (ada_language_data): Remove la_range_check
initializer.
* c-lang.c (c_language_data): Likewise.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_language_data): Likewise.
(f_language::range_checking_on_by_default): New member function.
* go-lang.c (go_language_data): Remove la_range_check initializer.
* language.c (enum range_mode): Moved here from language.h.
(range_mode): Made static.
(show_range_command): Update to use
range_checking_on_by_default.
(set_range_command): Likewise.
(set_range_case): Likewise.
(unknown_language_data): Remove la_range_check initializer.
(auto_language_data): Likewise.
* language.h (range_mode): Delete.  Enum definition moved to
language.c.
(language_data): Remove la_range_check field.
(language_defn::range_checking_on_by_default): New member
function.
* m2-lang.c (m2_language_data): Remove la_range_check initializer.
(m2_language::range_checking_on_by_default): New member function.
* objc-lang.c (objc_language_data): Remove la_range_check
initializer.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
(pascal_language::range_checking_on_by_default): New member
function.
* rust-lang.c (rust_language_data): Remove la_range_check
initializer.
(rust_language::range_checking_on_by_default): New member
function.

4 years agogdb: Override store_sym_names_in_linkage_form_p for Go language
Andrew Burgess [Wed, 8 Jul 2020 10:09:45 +0000 (11:09 +0100)]
gdb: Override store_sym_names_in_linkage_form_p for Go language

When store_sym_names_in_linkage_form_p was introduced in this commit:

  commit 59cc4834e53565da1de4a7b615ed8890ed55c7da
  Date:   Tue Mar 27 08:57:16 2018 -0500

      problem looking up some symbols when they have a linkage name

A special case was left behind for Go, however, this special case was
not really needed anymore, it could be handled by having
store_sym_names_in_linkage_form_p return the true for go, instead of
false.

This commit overrides store_sym_names_in_linkage_form_p for Go, and
then removes the special case.  As store_sym_names_in_linkage_form_p
is only called once throughout GDB this should be perfectly safe.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* dwarf2/read.c (dwarf2_physname): Remove special case for
language_go.
* go-lang.c (go_language::store_sym_names_in_linkage_form_p): New
member function.

4 years agogdb: Convert la_store_sym_names_in_linkage_form_p to a method
Andrew Burgess [Wed, 8 Jul 2020 09:55:56 +0000 (10:55 +0100)]
gdb: Convert la_store_sym_names_in_linkage_form_p to a method

Convert language_data::la_store_sym_names_in_linkage_form_p member
variable to language_defn::store_sym_names_in_linkage_form_p virtual
function.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (ada_language_data): Remove
la_store_sym_names_in_linkage_form_p initializer.
(ada_language::store_sym_names_in_linkage_form_p): New member
function.
* c-lang.c (c_language_data): Remove
la_store_sym_names_in_linkage_form_p initializer.
(c_language::store_sym_names_in_linkage_form_p): New member
function.
(cplus_language_data): Remove la_store_sym_names_in_linkage_form_p
initializer.
(asm_language_data): Likewise.
(asm_language::store_sym_names_in_linkage_form_p): New member
function.
(minimal_language_data): Remove
la_store_sym_names_in_linkage_form_p initializer.
(minimal_language::store_sym_names_in_linkage_form_p): New member
function.
* d-lang.c (d_language_data): Remove
la_store_sym_names_in_linkage_form_p initializer.
* dwarf2/read.c (dwarf2_physname): Update call to
store_sym_names_in_linkage_form_p.
* f-lang.c (f_language_data): Remove
la_store_sym_names_in_linkage_form_p initializer.
* go-lang.c (go_language_data): Remove
la_store_sym_names_in_linkage_form_p initializer.
* language.c (unknown_language_data): Remove
la_store_sym_names_in_linkage_form_p initializer.
(unknown_language::store_sym_names_in_linkage_form_p): New member
function.
(auto_language_data): Remove la_store_sym_names_in_linkage_form_p
initializer.
(auto_language::store_sym_names_in_linkage_form_p): New member
function.
* language.h (language_data): Remove
la_store_sym_names_in_linkage_form_p member variable.
(language_defn::store_sym_names_in_linkage_form_p): New member
function.
* m2-lang.c (m2_language_data): Remove
la_store_sym_names_in_linkage_form_p initializer.
* objc-lang.c (objc_language_data): Likewise.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_language_data): Likewise.

4 years agogdb: Convert language_data::string_lower_bound to a method
Andrew Burgess [Sun, 5 Jul 2020 08:29:34 +0000 (09:29 +0100)]
gdb: Convert language_data::string_lower_bound to a method

Convert language_data::string_lower_bound member variable to a virtual
method language_defn::string_lower_bound.

Over all of the languages we currently support there are currently
only two values for the lower bound, 0 or 1.  I noticed that in all
cases, if a language has C style arrays then the lower bound is 0,
otherwise the lower bound is 1.  So the default for the virtual method
in language.h makes use of this, which means languages don't have to
worry about providing a string_lower_bound method at all.

Except for Modula2.  This language is defined to not have C style
arrays, but has a string_lower_bound index of 0, this behaviour is
maintained after this commit by having Modula2 be the only language
that overrides the string_lower_bound method.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (ada_language_data): Remove string_lower_bound
initializer.
* c-lang.c (c_language_data): Likewise.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_language_data): Likewise.
* go-lang.c (go_language_data): Likewise.
* language.c (unknown_language_data): Likewise.
(auto_language_data): Likewise.
* language.h (language_data): Remove string_lower_bound field.
(language_defn::string_lower_bound): New member function.
* m2-lang.c (m2_language_data): Remove string_lower_bound
initializer.
(m2_language::string_lower_bound): New member function.
* objc-lang.c (objc_language_data): Remove string_lower_bound
initializer.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_language_data): Likewise.
* valops.c (value_cstring): Update call to string_lower_bound.
(value_string): Likewise.
* value.c (allocate_repeated_value): Likewise.

4 years agogdb: Fix an incorrect comment
Andrew Burgess [Sat, 4 Jul 2020 08:10:27 +0000 (09:10 +0100)]
gdb: Fix an incorrect comment

A comment uses the wrong parameter name.  Fixed in this commit.

gdb/ChangeLog:

* valops.c (value_repeat): Fix incorrect argument name in comment.

4 years agogdb: Convert language_data::c_style_arrays to a method
Andrew Burgess [Sat, 4 Jul 2020 08:06:08 +0000 (09:06 +0100)]
gdb: Convert language_data::c_style_arrays to a method

Convert language_data::c_style_arrays member variable to a virtual
method language_defn::c_style_arrays_p.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (ada_language_data): Remove c_style_arrays
initializer.
(ada_language::c_style_arrays_p): New member fuction.
* c-lang.c (c_language_data): Remove c_style_arrays
initializer.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* eval.c (ptrmath_type_p): Update call to c_style_arrays_p.
* f-lang.c (f_language_data): Remove c_style_arrays initializer.
(f_language::c_style_arrays_p): New member function.
* go-lang.c (go_language_data): Remove c_style_arrays initializer.
* infcall.c (value_arg_coerce): Update call to c_style_arrays_p.
* language.c (unknown_language_data): Remove c_style_arrays
initializer.
(auto_language_data): Likewise.
* language.h (language_data): Remove c_style_arrays field.
(language_defn::c_style_arrays_p): New member function.
* m2-lang.c (m2_language_data): Remove c_style_arrays initializer.
(m2_language::c_style_arrays_p): New member function.
* objc-lang.c (objc_language_data): Remove c_style_arrays
initializer.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_language_data): Likewise.
* valarith.c (value_subscript): Update call to c_style_arrays_p,
and update local variable to a bool.
* valops.c (value_cast): Update call to c_style_arrays_p.
(value_array): Likewise.
* value.c (coerce_array): Likewise.

4 years agogdb: Move la_language into the language_defn class
Andrew Burgess [Fri, 3 Jul 2020 17:51:34 +0000 (18:51 +0100)]
gdb: Move la_language into the language_defn class

Move the language_data::la_language member variable into the
langage_defn class.

I have not made the la_language member variable a method of
langage_defn simply because of the large number of places that
la_language is referenced throughout GDB.  I have made the new member
variable constant though, so this should prevent accidental
assignment.

In the future we might consider converting la_language to a method,
but right now my goal is to remove the langage_data class, so I'm
happy to leave la_language as a constant member variable.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (ada_language_data): Remove la_language initializer.
* c-lang.c (c_language_data): Likewise.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_language_data): Likewise.
* go-lang.c (go_language_data): Likewise.
* language.c (unknown_language_data): Likewise.
(auto_language_data): Likewise.
* language.h (language_data): Remove la_language field.
(language_defn::language_defn): Initialise la_language field.
(language_defn::la_language): New member variable.
* m2-lang.c (m2_language_data): Remove la_language field.
* objc-lang.c (objc_language_data): Likewise.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_language_data): Likewise.

4 years agogdb: Convert la_filename_extensions to a method
Andrew Burgess [Fri, 3 Jul 2020 17:46:16 +0000 (18:46 +0100)]
gdb: Convert la_filename_extensions to a method

Convert language_data::la_filename_extensions member variable to a
virtual method language_defn::filename_extensions.

The new method returns a vector of filename extensions, which means
that where previously we needed a NULL marker on the end of the list,
we can now discard this.

All of the old arrays that contained the extensions now become static
data within each languages filename_extensions method.

I've updated the single use of the filename_extensions method to make
use of this method returning a vector.  And, just in case anyone
accidentally adds a NULL marked into a languages extensions list, I've
added a new assert in add_filename_language (symtab.c) to catch this.

gdb/ChangeLog:

* ada-lang.c (ada_extensions): Delete, moved into
ada_language::filename_extensions.
(ada_language_data): Remove la_filename_extensions initializer.
(ada_language::filename_extensions): New member function.
* c-lang.c (c_extensions): Delete, moved into
c_language::filename_extensions.
(c_language_data): Remove la_filename_extensions initializer.
(c_language::filename_extensions): New member function.
(cplus_extensions): Delete, moved into
cplus_language::filename_extensions.
(cplus_language_data): Remove la_filename_extensions initializer.
(cplus_language::filename_extensions): New member function.
(asm_extensions): Delete, moved into
asm_language::filename_extensions.
(asm_language_data): Remove la_filename_extensions initializer.
(asm_language::filename_extensions): New member function.
(minimal_language_data): Remove la_filename_extensions
initializer.
* d-lang.c (d_extensions): Delete, moved into
d_language::filename_extensions.
(d_language_data): Remove la_filename_extensions initializer.
(d_language::filename_extensions): New member function.
* f-lang.c (f_extensions): Delete, moved into
f_language::filename_extensions.
(f_language_data): Remove la_filename_extensions initializer.
(f_language::filename_extensions): New member function.
* go-lang.c (go_language_data): Remove la_filename_extensions
initializer.
* language.c (add_set_language_command): Update now that
filename_extensions returns a vector.
(unknown_language_data): Remove la_filename_extensions
initializer.
(auto_language_data): Likewise.
* language.h (language_data): Remove la_filename_extensions field.
(language_defn::filename_extensions): New member function.
* m2-lang.c (m2_language_data): Remove la_filename_extensions
initializer.
* objc-lang.c (objc_extensions): Delete, moved into
objc_language::filename_extensions.
(objc_language_data): Remove la_filename_extensions initializer.
(objc_language::filename_extensions): New member function.
* opencl-lang.c (opencl_language_data): Remove
la_filename_extensions initializer.
* p-lang.c (pascal_extensions): Delete, moved into
pascal_language::filename_extensions.
(pascal_language_data): Remove la_filename_extensions initializer.
(pascal_language::filename_extensions): New member function.
* rust-lang.c (rust_extensions): Delete, moved into
rust_language::filename_extensions.
(rust_language_data): Remove la_filename_extensions initializer.
(rust_language::filename_extensions): New member function.
* symfile.c (add_filename_language): Add new assert.

4 years agogdb: Convert la_name and la_natural_name to methods
Andrew Burgess [Tue, 23 Jun 2020 19:07:09 +0000 (20:07 +0100)]
gdb: Convert la_name and la_natural_name to methods

Convert the two language_data member variables la_name and
la_natural_name to virtual methods in language_defn struct called name
and natural_name respectively.

The virtual methods in the language_defn base class are pure virtual,
as every language must implement these, and as every language has a
unique name there's no sensible default here.

Given that every language must implement these methods I did wonder
about making this data passed into the base class constructor, but in
the end I went with the virtual method approach.  I'm open to changing
this approach if people prefer the constructor approach.

During updating the calls to language_defn::name I found in
add_set_language_command a place where we took la_name and then
capitalised the first letter to create a language name that could be
used in the documentation string.  I replaced this with a use of
natural_name instead as this seemed a better choice, in most cases
this will make no difference, as for most languages the natural_name
is just the name with the first character in upper case, but for some
languages, for example 'Open-CL' and 'Objective-C' this is not the
case.

In the case of asm_language the name is 'asm', while the natural_name
was previously 'assembly'.  I changed the natural name to 'Assembly',
this makes the documentation string case above cleaner, however, this
will change the MI output for -var-info-expression, where the 'lang'
field will change from 'assembly' to 'Assembly'.  It is possible this
could be a breaking change if a front-end is relying on the existing
name.

gdb/ChangeLog:

* ada-lang.c (ada_language_data): Remove la_name and
la_natural_name initializers.
(ada_language::name): New member function.
(ada_language::natural_name): New member function.
* c-lang.c (c_language_data): Remove la_name and
la_natural_name initializers.
(c_language::name): New member function.
(c_language::natural_name): New member function.
(cplus_language_data): Remove la_name and
la_natural_name initializers.
(cplus_language::name): New member function.
(cplus_language::natural_name): New member function.
(asm_language_data): Remove la_name and
la_natural_name initializers.
(asm_language::name): New member function.
(asm_language::natural_name): New member function.
(minimal_language_data): Remove la_name and
la_natural_name initializers.
(minimal_language::name): New member function.
(minimal_language::natural_name): New member function.
* compile/compile.c (compile_to_object): Update call to
lanugage_defn::name.
* d-lang.c (d_language_data): Remove la_name and
la_natural_name initializers.
(d_language::name): New member function.
(d_language::natural_name): New member function.
* expprint.c (print_subexp_standard): Update call to
language_defn::name.
(dump_raw_expression): Likewise
(dump_prefix_expression): Likewise.
* f-lang.c (f_language_data): Remove la_name and
la_natural_name initializers.
(f_language::name): New member function.
(f_language::natural_name): New member function.
* go-lang.c (go_language_data): Remove la_name and
la_natural_name initializers.
(go_language::name): New member function.
(go_language::natural_name): New member function.
* language.c (show_language_command): Update call to
language_defn::name.
(set_language_command): Likewise.
(language_enum): Likewise.
(language_str): Likewise.
(add_set_language_command): Likewise, use
language_defn::natural_name in the doc string.
(unknown_language_data): Remove la_name and
la_natural_name initializers.
(unknown_language::name): New member function.
(unknown_language::natural_name): New member function.
(auto_language_data): Remove la_name and
la_natural_name initializers.
(auto_language::name): New member function.
(auto_language::natural_name): New member function.
(language_lookup_primitive_type_as_symbol): Update call to
language_defn::name.
* language.h (language_data): Remove la_name and la_natural_name
member variables.
(language_defn::name): New member function.
(language_defn::natural_name): New member function.
* m2-lang.c (m2_language_data): Remove la_name and
la_natural_name initializers.
(m2_language::name): New member function.
(m2_language::natural_name): New member function.
* mi/mi-cmd-var.c (mi_cmd_var_info_expression): Update call to
language_defn::natural_name.
* objc-lang.c (objc_language_data): Remove la_name and
la_natural_name initializers.
(objc_language::name): New member function.
(objc_language::natural_name): New member function.
* opencl-lang.c (opencl_language_data): Remove la_name and
la_natural_name initializers.
(opencl_language::name): New member function.
(opencl_language::natural_name): New member function.
* p-lang.c (pascal_language_data): Remove la_name and
la_natural_name initializers.
(pascal_language::name): New member function.
(pascal_language::natural_name): New member function.
* rust-lang.c (rust_language_data): Remove la_name and
la_natural_name initializers.
(rust_language::name): New member function.
(rust_language::natural_name): New member function.
* symtab.c (lookup_language_this): Update call to
language_defn::name.

4 years agogdb: Convert la_name_of_this to a method
Andrew Burgess [Tue, 23 Jun 2020 13:42:14 +0000 (14:42 +0100)]
gdb: Convert la_name_of_this to a method

Convert language_data::la_name_of_this member variable to a virtual
method language_defn::name_of_this.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (ada_language_data): Remove la_name_of_this
initializer.
* ax-gdb.c (gen_expr): Update call to name_of_this.
* c-exp.y (classify_name): Likewise.
* c-lang.c (c_language_data): Remove la_name_of_this initializer.
(cplus_language_data): Likewise.
(cplus_language::name_of_this): New member function.
(asm_language_data): Remove la_name_of_this initializer.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
(d_language::name_of_this): New member function.
* expprint.c (print_subexp_standard): Update call to name_of_this.
* f-lang.c (f_language_data): Remove la_name_of_this initializer.
* go-lang.c (go_language_data): Likewise.
* language.c (unknown_language_data): Likewise.
(unknown_language::name_of_this): New member function.
(auto_language_data): Remove la_name_of_this initializer.
(auto_language::name_of_this): New member function.
* language.h (language_data): Delete la_name_of_this member
variable.
(language_defn::name_of_this): New member function.
* m2-lang.c (m2_language_data): Remove la_name_of_this
initializer.
* objc-lang.c (objc_language_data): Likewise.
(objc_language::name_of_this): New member function.
* opencl-lang.c (opencl_language_data): Remove la_name_of_this
initializer.
* p-lang.c (pascal_language_data): Likewise.
(pascal_language::name_of_this): New member function.
* rust-lang.c (rust_language_data): Remove la_name_of_this
initializer.
* symtab.c (lookup_language_this): Update call to name_of_this.
(lookup_symbol_aux): Likewise.
* valops.c (value_of_this): Likewise.

4 years agogdb: Convert la_struct_too_deep_ellipsis to a method
Andrew Burgess [Tue, 23 Jun 2020 13:16:32 +0000 (14:16 +0100)]
gdb: Convert la_struct_too_deep_ellipsis to a method

Convert language_data::la_struct_too_deep_ellipsis member variable to
a method in language_defn.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (ada_language_data): Remove
la_struct_too_deep_ellipsis initializer.
(ada_language::struct_too_deep_ellipsis): New member function.
* c-lang.c (c_language_data): Remove la_struct_too_deep_ellipsis
initializer.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* cp-valprint.c (cp_print_value): Update call to
struct_too_deep_ellipsis.
* d-lang.c (d_language_data): Remove la_struct_too_deep_ellipsis
initializer.
* f-lang.c (f_language_data): Likewise.
(f_language::struct_too_deep_ellipsis): New member function.
* go-lang.c (go_language_data): Remove la_struct_too_deep_ellipsis
initializer.
* language.c (unknown_language_data): Likewise.
(auto_language_data): Likewise.
* language.h (language_data): Delete la_struct_too_deep_ellipsis
member variable.
(language_defn::struct_too_deep_ellipsis): New member function.
* m2-lang.c (m2_language_data): Remove la_struct_too_deep_ellipsis
initializer.Q
* objc-lang.c (objc_language_data): Likewise.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_language_data): Likewise.
* valprint.c (val_print_check_max_depth): Update call to
struct_too_deep_ellipsis.

4 years agoAdd myself to gdb/MAINTAINERS.
Felix Willgerodt [Wed, 16 Sep 2020 08:04:53 +0000 (10:04 +0200)]
Add myself to gdb/MAINTAINERS.

gdb/ChangeLog:
2020-09-16  Felix Willgerodt  <felix.willgerodt@intel.com>

* MAINTAINERS (Write After Approval): Add myself.

4 years ago[gdb/testsuite] Fix unbalanced braces in gdb.tui/new-layout.exp
Tom de Vries [Wed, 16 Sep 2020 08:57:17 +0000 (10:57 +0200)]
[gdb/testsuite] Fix unbalanced braces in gdb.tui/new-layout.exp

On SLE-11 with tcl version 8.5, we run into:
...
UNRESOLVED: gdb.tui/new-layout.exp: testcase aborted due to \
  invalid command name: }
ERROR: Couldn't send tui new-layout example src 1} to GDB.
...

Apparently tcl 8.6 is more forgiving about unbalanced braces.

Expose the unbalanced braces on tcl 8.6 by temporarily wrapping the
test-case in:
...
proc do_this { args } {
    uplevel 1 {*}$args
}

do_this {
  ...
}
...
and escape them using a backslash.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

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

PR testsuite/26618
* gdb.tui/new-layout.exp: Escape unbalanced braces.

4 years agoTidy elf_symbol_from
Alan Modra [Tue, 15 Sep 2020 23:55:56 +0000 (09:25 +0930)]
Tidy elf_symbol_from

bfd/
* elf-bfd.h (elf_symbol_from): Remove unused ABFD parameter.
* elf.c (ignore_section_sym, _bfd_elf_copy_private_symbol_data),
(swap_out_syms): Adjust elf_symbol_from invocation.
binutils/
* nm.c (print_symbol): Adjust elf_symbol_from invocation.
* objcopy.c (is_hidden_symbol): Likewise.
gas/
* config/obj-elf.c (obj_elf_visibility, elf_frob_symbol): Adjust
elf_symbol_from invocation.
* config/tc-aarch64.c (s_variant_pcs): Likewise.
* config/tc-m68hc11.c (s_m68hc11_mark_symbol): Likewise.
* config/tc-ppc.c (ppc_elf_localentry, ppc_force_relocation),
(ppc_fix_adjustable): Likewise.
* config/tc-xgate.c (xgate_frob_symbol): Likewise.
ld/
* plugin.c (asymbol_from_plugin_symbol): Adjust elf_symbol_from
invocation.
opcodes/
* ppc-dis.c (ppc_symbol_is_valid): Adjust elf_symbol_from invocation.

4 years agoPR26623, buffer overflow in ppc_symbol_is_valid
Alan Modra [Tue, 15 Sep 2020 23:52:36 +0000 (09:22 +0930)]
PR26623, buffer overflow in ppc_symbol_is_valid

PR 26623
* elf-bfd.h (elf_symbol_from): Exclude synthetic symbols.

4 years agoRemove TYPE_CODE_INT case from f_value_print_inner
Tom Tromey [Wed, 16 Sep 2020 00:44:37 +0000 (18:44 -0600)]
Remove TYPE_CODE_INT case from f_value_print_inner

I looked through the various language value-print functions, to see if
any code could be consolidated.  Pretty much all I found was that
f_value_print_inner does not need to handle TYPE_CODE_INT itself, but
can simply dispatch to the generic printer.

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

* f-valprint.c (f_value_print_inner) <case TYPE_CODE_INT>:
Remove.

4 years agoHandle member pointers directly in generic_value_print
Tom Tromey [Wed, 16 Sep 2020 00:44:37 +0000 (18:44 -0600)]
Handle member pointers directly in generic_value_print

TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR are only used for C++, so
it seems to me that the generic value-printing code ought to handle
these cases -- that way, printing these objects will work even when
the current language is not C++.  This patch implements this idea.

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

* rust-lang.c (rust_value_print_inner): Remove TYPE_CODE_MEMBERPTR
and TYPE_CODE_METHODPTR cases.
* c-valprint.c (c_value_print_memberptr): Move to valprint.c.
(c_value_print_inner): Update.
* valprint.c (generic_value_print_memberptr): New function, from
c_value_print_memberptr.
(generic_value_print): Use it.  Call cplus_print_method_ptr.

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

4 years agoPE/x86-64: Display PE relocation names
H.J. Lu [Tue, 15 Sep 2020 20:56:18 +0000 (13:56 -0700)]
PE/x86-64: Display PE relocation names

For PE/x86-64, display PE relocation names:

R_X86_64_64   -> IMAGE_REL_AMD64_ADDR64
R_X86_64_32   -> IMAGE_REL_AMD64_ADDR32.
rva32         -> IMAGE_REL_AMD64_ADDR32NB
R_X86_64_PC32 -> IMAGE_REL_AMD64_REL32
DISP32+1      -> IMAGE_REL_AMD64_REL32_1
DISP32+2      -> IMAGE_REL_AMD64_REL32_2
DISP32+3      -> IMAGE_REL_AMD64_REL32_3
DISP32+4      -> IMAGE_REL_AMD64_REL32_4
DISP32+5      -> IMAGE_REL_AMD64_REL32_5
secrel32      -> IMAGE_REL_AMD64_SECREL

bfd/

* coff-x86_64.c (howto_table): Display PE relocation names.

gas/

* testsuite/gas/cfi/reloc-pe-i386.d: Updated.
* testsuite/gas/i386/x86-64-w64-pcrel.d: Likewise.

4 years agoelf: Check bfd_target_elf_flavour on input first
H.J. Lu [Tue, 15 Sep 2020 20:05:04 +0000 (13:05 -0700)]
elf: Check bfd_target_elf_flavour on input first

Check bfd_target_elf_flavour on input first in ldelf_after_open before
checking elf_tdata.

* ldelf.c (ldelf_after_open): Check bfd_target_elf_flavour first.

4 years agoDon't use PyInt_FromLong
Tom Tromey [Tue, 15 Sep 2020 17:08:56 +0000 (11:08 -0600)]
Don't use PyInt_FromLong

Avoid the use of PyInt_FromLong, preferring gdb_py_object_from_longest
instead.  I found found another spot that was incorrectly handling
errors (see gdbpy_create_ptid_object) while writing this patch; it is
fixed here.

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

* python/python-internal.h (PyInt_FromLong): Remove define.
* python/py-value.c (convert_value_from_python): Use
gdb_py_object_from_longest.
* python/py-type.c (typy_get_code): Use
gdb_py_object_from_longest.
* python/py-symtab.c (salpy_get_line): Use
gdb_py_object_from_longest.
* python/py-symbol.c (sympy_get_addr_class, sympy_line): Use
gdb_py_object_from_longest.
* python/py-record.c (recpy_gap_reason_code): Use
gdb_py_object_from_longest.
* python/py-record-btrace.c (recpy_bt_insn_size)
(recpy_bt_func_level, btpy_list_count): Use
gdb_py_object_from_longest.
* python/py-infthread.c (gdbpy_create_ptid_object): Use
gdb_py_object_from_longest.  Fix error handling.
* python/py-framefilter.c (bootstrap_python_frame_filters): Use
gdb_py_object_from_longest.
* python/py-frame.c (frapy_type, frapy_unwind_stop_reason): Use
gdb_py_object_from_longest.
* python/py-breakpoint.c (bppy_get_type, bppy_get_number)
(bppy_get_thread, bppy_get_task, bppy_get_hit_count)
(bppy_get_ignore_count): Use gdb_py_object_from_longest.

4 years agoDon't use PyLong_FromUnsignedLong
Tom Tromey [Tue, 15 Sep 2020 17:08:56 +0000 (11:08 -0600)]
Don't use PyLong_FromUnsignedLong

This changes gdb to avoid PyLong_FromUnsignedLong, preferring
gdb_py_object_from_ulongest instead.

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

* python/python.c (gdbpy_parameter_value): Use
gdb_py_object_from_ulongest.

4 years agoDon't use PyLong_FromLongLong
Tom Tromey [Tue, 15 Sep 2020 17:08:56 +0000 (11:08 -0600)]
Don't use PyLong_FromLongLong

This changes gdb to avoid PyLong_FromLongLong, preferring to use
gdb_py_object_from_longest instead.

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

* python/py-infevents.c (create_register_changed_event_object):
Use gdb_py_object_from_longest.
* python/py-exitedevent.c (create_exited_event_object): Use
gdb_py_object_from_longest.

4 years agoDon't use PyLong_FromLong
Tom Tromey [Tue, 15 Sep 2020 17:08:56 +0000 (11:08 -0600)]
Don't use PyLong_FromLong

This changes gdb to avoid PyLong_FromLong, preferring to
gdb_py_object_from_longest instead.

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

* python/python.c (gdbpy_parameter_value): Use
gdb_py_object_from_longest.
* python/py-type.c (convert_field, typy_range): Use
gdb_py_object_from_longest.
* python/py-tui.c (gdbpy_tui_width, gdbpy_tui_height): Use
gdb_py_object_from_longest.
* python/py-lazy-string.c (stpy_get_length): Use
gdb_py_object_from_longest.
* python/py-infthread.c (thpy_get_num, thpy_get_global_num): Use
gdb_py_object_from_longest.
* python/py-infevents.c (create_memory_changed_event_object): Use
gdb_py_object_from_longest.
* python/py-inferior.c (infpy_get_num): Use
gdb_py_object_from_longest.
(infpy_get_pid): Likewise.

4 years agoDon't use gdb_py_long_from_ulongest
Tom Tromey [Tue, 15 Sep 2020 17:08:56 +0000 (11:08 -0600)]
Don't use gdb_py_long_from_ulongest

Remove the gdb_py_long_from_ulongest defines and change the Python
layer to prefer gdb_py_object_from_ulongest.  While writing this I
noticed that the error handling in archpy_disassemble was incorrect --
it could call PyDict_SetItemString with a NULL value.  This patch also
fixes this bug.

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

* python/python-internal.h (gdb_py_long_from_ulongest): Remove
defines.
* python/py-value.c (valpy_long): Use
gdb_py_object_from_ulongest.
* python/py-symtab.c (salpy_get_pc): Use
gdb_py_object_from_ulongest.
(salpy_get_last): Likewise.
* python/py-record-btrace.c (recpy_bt_insn_pc): Use
gdb_py_object_from_ulongest.
* python/py-lazy-string.c (stpy_get_address): Use
gdb_py_object_from_ulongest.
* python/py-frame.c (frapy_pc): Use gdb_py_object_from_ulongest.
* python/py-arch.c (archpy_disassemble): Use
gdb_py_object_from_ulongest and gdb_py_object_from_longest.  Fix
error handling.

4 years agoDon't use gdb_py_long_from_longest
Tom Tromey [Tue, 15 Sep 2020 17:08:56 +0000 (11:08 -0600)]
Don't use gdb_py_long_from_longest

Change the Python layer to avoid gdb_py_long_from_longest, and remove
the defines.

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

* python/python-internal.h (gdb_py_long_from_longest): Remove
defines.
* python/py-value.c (valpy_long): Use gdb_py_object_from_longest.
* python/py-type.c (convert_field, typy_get_sizeof): Use
gdb_py_object_from_longest.
* python/py-record-btrace.c (btpy_list_index): Use
gdb_py_object_from_longest.

4 years agoDon't use PyInt_FromSsize_t
Tom Tromey [Tue, 15 Sep 2020 17:08:56 +0000 (11:08 -0600)]
Don't use PyInt_FromSsize_t

Change the Python layer to avoid PyInt_FromSsize_t, and remove the
compatibility define.

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

* python/python-internal.h (PyInt_FromSsize_t): Remove define.
* python/py-record.c (recpy_element_number): Use
gdb_py_object_from_longest.
(recpy_gap_number): Likewise.

4 years agoAvoid running one Rust test against older LLVM
Tom Tromey [Tue, 15 Sep 2020 15:27:01 +0000 (09:27 -0600)]
Avoid running one Rust test against older LLVM

LLVM 8.0 introduced some changes to let the Rust compiler emit DWARF
variant parts.  Before this change, the compiler would emit two types
with the same name, and unfortunately gdb happens to pick the wrong
one.  So, this patch disables the test when using an older version of
LLVM.

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

PR rust/26197:
* lib/rust-support.exp (rust_llvm_version): New proc.
* gdb.rust/simple.exp: Check rust_llvm_version.

4 years agoRemove ui::num
Tom Tromey [Tue, 15 Sep 2020 14:54:03 +0000 (08:54 -0600)]
Remove ui::num

I noticed that nothing uses ui::num, so this patch removes it.

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

* top.c (ui::ui): Update.
(highest_ui_num): Remove.
* top.h (struct ui) <num>: Remove.

4 years agoUse arrays rather than pointers for global string constants
Tom Tromey [Tue, 15 Sep 2020 14:38:22 +0000 (08:38 -0600)]
Use arrays rather than pointers for global string constants

My understanding is that it's mildly better to use a static const
array, as opposed to a "const char *", for a global string constant,
when possible.  This makes sense to me because the pointer requires a
load from an address, whereas the array is just the address.

So, I searched for these in gdb and gdbserver.  This patch fixes the
ones I found.

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

* unittests/memory-map-selftests.c (valid_mem_map): Now array.
* ui-style.c (ansi_regex_text): Now array.
* rust-exp.y (number_regex_text): Now array.
* linespec.c (linespec_quote_characters): Now array.
* jit.c (jit_break_name, jit_descriptor_name, reader_init_fn_sym):
Now arrays.

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

* linux-x86-low.cc (xmltarget_i386_linux_no_xml)
(xmltarget_amd64_linux_no_xml): Now arrays.

4 years agoPR26610, ARM's "VFPv3 vldr to vmov" gas testcase fail
Alan Modra [Tue, 15 Sep 2020 11:25:02 +0000 (20:55 +0930)]
PR26610, ARM's "VFPv3 vldr to vmov" gas testcase fail

I removed a few too many parentheses in git commit 7af677524e2.  This
patch fixes that problem, rewriting the expression so it won't happen
again.  The patch also avoids more UB with shifts of signed values.

PR 26610
* config/tc-arm.c (move_or_literal_pool): Correct extraction of
bignum.  Use unsigned "v"
(is_double_a_single): Make "v" and "mantissa" unsigned.  Formatting.
(double_to_single): Likewise.

4 years agoAdd note about creating a bugzilla tag for a point release.
Nick Clifton [Tue, 15 Sep 2020 10:32:34 +0000 (11:32 +0100)]
Add note about creating a bugzilla tag for a point release.

* README-how-to-make-a-release (https): Add a reminder to create a
new Bugzilla tag for the point release, once it has been published.

4 years agoFix the assembler's new .nop directive so that the input line pointer is preserved.
Nick Clifton [Tue, 15 Sep 2020 09:53:46 +0000 (10:53 +0100)]
Fix the assembler's new .nop directive so that the input line pointer is preserved.

* read.c (s_nop): Preserve the input_line_pointer around the call
to md_assemble.
* config/tc-s12z.c (md_assemble): Revert previous delta.

4 years agoChange the /nop directive for the BPF port of the assembler to use the encoding expec...
David Faust [Tue, 15 Sep 2020 09:33:49 +0000 (10:33 +0100)]
Change the /nop directive for the BPF port of the assembler to use the encoding expected by the kernel.

* config/tc-bpf.h (md_single_noop_insn): Use 'ja 0' for no-op.

4 years agogdb: introduce debuginfod_client_up type
Simon Marchi [Tue, 15 Sep 2020 02:28:42 +0000 (22:28 -0400)]
gdb: introduce debuginfod_client_up type

Introduce and use a unique pointer specialization for the
debuginfod_client type.  The deleter calls debuginfod_end to free the
client.

gdb/ChangeLog:

* debuginfod-support.c (debuginfod_client_deleter): New.
(debuginfod_client_up): New.
(debuginfod_init): Return debuginfod_client_up.
(debuginfod_source_query): Adjust.
(debuginfod_debuginfo_query): Adjust.

Change-Id: Ie56441e123ab80b78e5311c824c162cd804f68c0

4 years agogdb: use make_unique_xstrdup in debuginfod-support.c
Simon Marchi [Tue, 15 Sep 2020 02:28:25 +0000 (22:28 -0400)]
gdb: use make_unique_xstrdup in debuginfod-support.c

Use make_unique_xstrdup instead of reset + xstrdup.

gdb/ChangeLog:

* debuginfod-support.c (debuginfod_source_query): Use
make_unique_xstrdup.

Change-Id: Iee9524fea7630b4d6ee5c74e30c60fe222dc1d2c

4 years agogdb: remove TYPE_INSTANCE_FLAGS
Simon Marchi [Tue, 15 Sep 2020 02:22:33 +0000 (22:22 -0400)]
gdb: remove TYPE_INSTANCE_FLAGS

Remove it, use the `type::instance_flags` method everywhere.

gdb/ChangeLog:

* gdbtypes.h (TYPE_INSTANCE_FLAGS): Remove, replace all uses
with `type::instance_flags`.

Change-Id: I3653108b712e6186529cb0102e2b70247bbcabbe

4 years agoCRIS: fix PR ld/26589, a missing NULL check in fix for PR ld/22269
Hans-Peter Nilsson [Tue, 15 Sep 2020 00:57:39 +0000 (02:57 +0200)]
CRIS: fix PR ld/26589, a missing NULL check in fix for PR ld/22269

Not sure why there wasn't a NULL check in the ld/22269 patch
(e01c16a8) at the time, as there was one for the corresponding patch
to elf32-m68k.c (5056ba1d).

Incidentally, I had missed that in 2017, as a prerequisite for the
ld/22269 series, the check_relocs function finally were made "safe"!
(I.e. the number of references and symbol types are final, garbage
collection done, so port-specific accounting can be made sanely.)

Committed.

bfd:
PR ld/26589
* elf32-cris.c (cris_elf_check_relocs): Add missing NULL check
on argument before calling UNDEFWEAK_NO_DYNAMIC_RELOC.

ld:
PR ld/26589
* testsuite/ld-elf/pr26589.d, testsuite/ld-elf/locref3.s: New test.

4 years agogdb: fix compile break when HAVE_LIBEXPAT is not defined
Michael Mullin [Tue, 15 Sep 2020 00:39:54 +0000 (20:39 -0400)]
gdb: fix compile break when HAVE_LIBEXPAT is not defined

Fixes:

      CXX    xml-tdesc.o
    /home/smarchi/src/binutils-gdb/gdb/xml-tdesc.c: In function const target_desc* file_read_description_xml(const char*):
    /home/smarchi/src/binutils-gdb/gdb/xml-tdesc.c:681:60: error: too few arguments to function target_desc* tdesc_parse_xml(const char*, xml_fetch_another, void*)
      681 |   return tdesc_parse_xml (tdesc_str->data (), fetch_another);
          |                                                            ^
    /home/smarchi/src/binutils-gdb/gdb/xml-tdesc.c:44:1: note: declared here
       44 | tdesc_parse_xml (const char *document, xml_fetch_another fetcher,
          | ^~~~~~~~~~~~~~~

Commit 8400a90d19c5 ("gdb: change xml_fetch_another a function_view")
removed the `baton` parameter of `tdesc_parse_xml`, but didn't update
the version of the function used when GDB is built with no libexpat
support.  Remove the parameter in that definition too.

gdb/ChangeLog:

* xml-tdesc.c [!defined(HAVE_LIBEXPAT)] (tdesc_parse_xml):
Remove baton parameter.

Change-Id: I4ad29fbb7c3323f30ce5204c2976eaea16151a2e

This page took 0.115036 seconds and 5 git commands to generate.