Commit Graph

103497 Commits

Author SHA1 Message Date
Pedro Alves
81f904895e 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.
2020-09-18 00:06:39 +01:00
Pedro Alves
0a229804ab 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.
2020-09-18 00:06:17 +01:00
Pedro Alves
c3e5138dcc 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".
2020-09-18 00:05:57 +01:00
Pedro Alves
151fdbad7a 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.
2020-09-18 00:05:39 +01:00
Pedro Alves
18a25b6481 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.
2020-09-18 00:05:10 +01:00
Pedro Alves
11fac33796 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++.
2020-09-18 00:04:47 +01:00
Pedro Alves
52626c5826 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".
2020-09-18 00:04:29 +01:00
Pedro Alves
52bb090268 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.
2020-09-18 00:04:12 +01:00
Pedro Alves
73e18ac9da 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".
2020-09-18 00:03:37 +01:00
Pedro Alves
c8b188085d 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".
2020-09-17 23:33:40 +01:00
Tom Tromey
c1e1314d00 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.
2020-09-17 14:28:06 -06:00
Hannes Domani
0363df3db7 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.
2020-09-17 22:17:01 +02:00
Tom Tromey
280a9412e4 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.
2020-09-17 11:58:56 -06:00
Tom Tromey
6108fd1823 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.
2020-09-17 11:58:56 -06:00
Tom Tromey
fa9b11648c 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.
2020-09-17 11:58:56 -06:00
Tom Tromey
eb53f10555 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.
2020-09-17 11:58:56 -06:00
Tom Tromey
7a8a5d47c3 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.
2020-09-17 11:58:56 -06:00
Tom Tromey
99032cfcc6 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.
2020-09-17 11:58:56 -06:00
Tom Tromey
32580f6d2e 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.
2020-09-17 11:58:56 -06:00
Tom Tromey
c1fb98360c 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.
2020-09-17 11:58:56 -06:00
Tom Tromey
88f07206fa 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.
2020-09-17 11:58:56 -06:00
Tom Tromey
9519b2eea0 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.
2020-09-17 08:06:01 -06:00
Mikael Pettersson
dd80eb2cff 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.
2020-09-17 10:45:39 +01:00
Chungyi Chi
d2cd411356 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.
2020-09-17 09:45:50 +01:00
Alan Modra
848471acef 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.
2020-09-17 17:42:53 +09:30
Andrew Burgess
c568ac5ff7 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.
2020-09-17 14:52:05 +08:00
GDB Administrator
c2f876e11e Automatic date update in version.in 2020-09-17 00:00:07 +00:00
Simon Marchi
b650a28273 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
2020-09-16 17:26:45 -04:00
Simon Marchi
4d0bcfcf62 gdb: update instance_flags field name in gdb-gdb.py.in
Commit 314ad88df6 ("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
2020-09-16 16:43:39 -04:00
Tom Tromey
fe83066292 Match demangled name in "skip"
PR gdb/26598 notes that, before commit bcfe6157ca ("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.
2020-09-16 13:32:38 -06:00
John Baldwin
fe5ddfc3ee 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.
2020-09-16 11:40:05 -07:00
John Baldwin
e911c6663b 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.
2020-09-16 11:40:05 -07:00
John Baldwin
1f17d37249 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.
2020-09-16 11:40:05 -07:00
John Baldwin
bcb1da7fb7 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.
2020-09-16 11:40:05 -07:00
John Baldwin
5515f72973 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.
2020-09-16 11:40:04 -07:00
Tom de Vries
945ff6e213 [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.
2020-09-16 18:04:37 +02:00
Mikael Pettersson
be7628ca50 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.
2020-09-16 16:20:51 +01:00
Nick Clifton
7def086592 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.
2020-09-16 16:19:53 +01:00
Tankut Baris Aktemur
da1df1db9a 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.
2020-09-16 16:22:01 +02:00
H.J. Lu
36068e2fa5 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.
2020-09-16 07:11:31 -07:00
Tom de Vries
337882d477 [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".
2020-09-16 14:53:26 +02:00
Anatoly Parshintsev
0690f59128 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.
2020-09-16 13:17:24 +01:00
Tom de Vries
7361f908da [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.
2020-09-16 13:27:32 +02:00
Andrew Burgess
0e25e76727 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.
2020-09-16 11:04:04 +01:00
Andrew Burgess
b7c6e27dbb 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.
2020-09-16 11:04:04 +01:00
Andrew Burgess
5aba6ebefb 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.
2020-09-16 11:04:04 +01:00
Andrew Burgess
b63a3f3fc4 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.
2020-09-16 11:04:03 +01:00
Andrew Burgess
1ac14a0402 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.
2020-09-16 11:04:03 +01:00
Andrew Burgess
3a3440fb8b 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.
2020-09-16 11:04:03 +01:00
Andrew Burgess
0d201fa460 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.
2020-09-16 11:04:03 +01:00