Commit Graph

108850 Commits

Author SHA1 Message Date
John Baldwin
2ddd4c6082 fbsd-nat: Add include for gdb_argv. 2022-01-19 08:30:38 -08:00
Alan Modra
8ffb6df2aa PowerPC64 DT_RELR ELFv1
More fun with R_PPC64_NONE found in .opd.  Fixed by the
allocate_dynrelocs and ppc64_elf_size_dynamic_sections changes, and
since we are doing ifunc, opd and SYMBOL_REFERENCES_LOCAL tests later,
don't duplicate that work in check_relocs.

	* elf64-ppc.c (ppc64_elf_check_relocs): Remove opd and ifunc
	conditions for rel_count.
	(dec_dynrel_count): Likewise.
	(allocate_dynrelocs): Test for opd and ifunc when allocating
	relative relocs.
	(ppc64_elf_size_dynamic_sections): Likewise.
2022-01-19 16:45:45 +10:30
Alan Modra
edca615ac1 PowerPC64 DT_RELR local PLT
Similarly to the local GOT case.

	* elf64-ppc.c (ppc64_elf_size_dynamic_sections): Don't allocate
	space for PLT relocs against local syms when enable_dt_relr.
2022-01-19 16:45:45 +10:30
Alan Modra
8f22c9532b PowerPC64 DT_RELR local GOT
Fixes another case where we end up with superfluous R_PPC64_NONE.

	* elf64-ppc.c (ppc64_elf_size_dynamic_sections): Don't allocate
	space for GOT relocs against non-TLS local syms when enable_dt_relr.
	(ppc64_elf_layout_multitoc): Likewise.
2022-01-19 16:45:45 +10:30
GDB Administrator
05900cefe2 Automatic date update in version.in 2022-01-19 00:00:10 +00:00
Alan Modra
858b0eff3c Re: PowerPC64 DT_RELR
HJ: "There are 238 R_PPC64_NONEs in libc.so.6 alone."
Indeed, let's make them go away.  I had the SYMBOL_REFERENCES_LOCAL
test in the wrong place.  check_relocs is too early to know whether a
symbol is dynamic in a shared library.  Lots of glibc symbols are made
local by version script, but that doesn't happen until
size_dynamic_sections.

	* elf64-ppc.c (ppc64_elf_check_relocs): Don't count relative relocs
	here depending on SYMBOL_REFERENCES_LOCAL.
	(dec_dynrel_count): Likewise.
	(allocate_dynrelocs): Do so here instead.
2022-01-19 09:44:15 +10:30
Tom Tromey
72a52f2a86 Fix the remote-sim.c build
My earlier patch to move gdb_argv broke the remote-sim.c build.  This
patch fixes the bug.  I'm checking it in.
2022-01-18 14:12:23 -07:00
Simon Marchi
91f94053dd gdbserver: introduce remote_debug_printf
Add remote_debug_printf, and use it for all debug messages controlled by
remote_debug.

Change remote_debug to be a bool, which is trivial in this case.

Change-Id: I90de13cb892faec3830047b571661822b126d6e8
2022-01-18 13:44:38 -05:00
Simon Marchi
c058728c31 gdbserver: introduce threads_debug_printf, THREADS_SCOPED_DEBUG_ENTER_EXIT
Add the threads_debug_printf and THREADS_SCOPED_DEBUG_ENTER_EXIT, which
use the logging infrastructure from gdbsupport/common-debug.h.  Replace
all debug_print uses that are predicated by debug_threads with
threads_dethreads_debug_printf.  Replace uses of the debug_enter and
debug_exit macros with THREADS_SCOPED_DEBUG_ENTER_EXIT, which serves
essentially the same purpose, but allows showing what comes between the
enter and the exit in an indented form.

Note that "threads" debug is currently used for a bit of everything in
GDBserver, not only threads related stuff.  It should ideally be cleaned
up and separated logically as is done in GDB, but that's out of the
scope of this patch.

Change-Id: I2d4546464462cb4c16f7f1168c5cec5a89f2289a
2022-01-18 13:44:32 -05:00
Simon Marchi
c68665c726 gdbserver: turn debug_threads into a boolean
debug_threads is always used as a boolean.  Except in ax.cc and
tracepoint.cc.  These files have their own macros that use
debug_threads, and have a concept of verbosity level.  But they both
have a single level, so it's just a boolean in the end.

Remove this concept of level.  If we ever want to re-introduce it, I
think it will be better implemented in a more common location.

Change debug_threads to bool and adjust some users that were treating it
as an int.

Change-Id: I137f596eaf763a08c977dd74417969cedfee9ecf
2022-01-18 13:44:32 -05:00
Tom Tromey
d66beefaf6 Simplify Ada catchpoints
All the Ada catchpoints use the same breakpoint_ops contents, because
the catchpoint itself records its kind.  This patch simplifies the
code by removing the redundant ops structures.
2022-01-18 10:34:05 -07:00
Tom Tromey
de8e4cb3af Move "catch exec" to a new file
The "catch exec" code is reasonably self-contained, and so this patch
moves it out of breakpoint.c (the second largest source file in gdb)
and into a new file, break-catch-exec.c.
2022-01-18 10:34:05 -07:00
Tom Tromey
064f3c6a01 Move "catch fork" to a new file
The "catch fork" code is reasonably self-contained, and so this patch
moves it out of breakpoint.c (the second largest source file in gdb)
and into a new file, break-catch-fork.c.
2022-01-18 10:34:05 -07:00
Tom Tromey
59505f2cec Unify "catch fork" and "catch vfork"
I noticed that "catch fork" and "catch vfork" are nearly identical.
This patch simplifies the code by unifying these two cases.
2022-01-18 10:34:05 -07:00
Tom Tromey
d322d6d69d Move gdb_regex to gdbsupport
This moves the gdb_regex convenience class to gdbsupport.
2022-01-18 10:14:43 -07:00
Tom Tromey
0589ca4e7b Introduce gdb-hashtab module in gdbsupport
gdb has some extensions and helpers for working with the libiberty
hash table.  This patch consolidates these and moves them to
gdbsupport.
2022-01-18 10:14:43 -07:00
Tom Tromey
bf31fd38f0 Move gdb obstack code to gdbsupport
This moves the gdb-specific obstack code -- both extensions like
obconcat and obstack_strdup, and things like auto_obstack -- to
gdbsupport.
2022-01-18 10:14:42 -07:00
Tom Tromey
7904e9613e Move gdb_argv to gdbsupport
This moves the gdb_argv class to a new header in gdbsupport.
2022-01-18 10:14:42 -07:00
Tom Tromey
5947982f1d Simplify event_location_probe
event_location_probe currently stores two strings, but really only
needs one.  This patch simplifies it and removes some unnecessary
copies as well.
2022-01-18 10:01:20 -07:00
Tom Tromey
85e428a69f Use std::string in event_location
This changes event_location to use std::string, removing some manual
memory management, and an unnecessary string copy.
2022-01-18 10:01:19 -07:00
Tom Tromey
2b0c285ea5 Split event_location into subclasses
event_location uses the old C-style discriminated union approach.
However, it's better to use subclassing, as this makes the code
clearer and removes some chances for error.  This also enables future
cleanups to avoid manual memory management and copies.
2022-01-18 10:01:16 -07:00
Tom Tromey
49a9cf56ff Remove EL_* macros from location.c
This patch removes the old-style EL_* macros from location.c.  This
cleans up the code by itself, IMO, but also enables further cleanups
in subsequent patches.
2022-01-18 10:00:01 -07:00
Tom Tromey
7910e2dee3 Boolify explicit_to_string_internal
This changes explicit_to_string_internal to use 'bool' rather than
'int'.
2022-01-18 10:00:00 -07:00
Tom Tromey
dab863ef40 Remove a use of xfree in location.c
This small cleanup removes a use of xfree from location.c, by
switching to unique_xmalloc_ptr.  One function is only used in
location.c, so it is made static.  And, another function is changed to
avoid a copy.
2022-01-18 10:00:00 -07:00
Simon Marchi
e53c95d40b gdb: use ptid_t::to_string instead of target_pid_to_str in debug statements
Same idea as 0fab795564 ("gdb: use ptid_t::to_string in infrun debug
messages"), but throughout GDB.

Change-Id: I62ba36eaef29935316d7187b9b13d7b88491acc1
2022-01-18 11:28:33 -05:00
Andrew Burgess
cced7cacec gdb: preserve | in connection details string
Consider this GDB session:

  $ gdb -q
  (gdb) target remote  | gdbserver - ~/tmp/hello.x
  Remote debugging using | gdbserver - ~/tmp/hello.x
  ... snip ...
  (gdb) info connections
    Num  What                              Description
  * 1    remote gdbserver - ~/tmp/hello.x  Remote target using gdb-specific protocol
  (gdb) python conn = gdb.selected_inferior().connection
  (gdb) python print(conn.details)
  gdbserver - ~/tmp/hello.x
  (gdb)

I think there are two things wrong here, first in the "What" column of
the 'info connections' output, I think the text should be:

  remote | gdbserver - ~/tmp/hello.x

to correctly show the user how the connection was established.  And in
a similar fashion, I think that the `details` string of the
gdb.TargetConnection object should be:

  | gdbserver - ~/tmp/hello.x

This commit makes this change.  Currently the '|' is detected and
removed in gdb/serial.c.  The string passed to the pipe_ops
structure (from gdb/ser-pipe.c), doesn't then, contain the `|`, this
is instead implied by the fact that it is a pipes based implementation
of the serial_ops interface.

After this commit we still detect the `|` in gdb/serial.c, but we now
store the full string (including the `|`) in the serial::name member
variable.

For pipe based serial connections, this name is only used for
displaying the two fields I mention above, and in pipe_open (from
gdb/ser-pipe.c), and in pipe_open, we now know to skip over the `|`.

The benefit I see from this change is that GDB's output now more
accurately reflects the commands used to start a target, thus making
it easier for a user to understand what is going on.
2022-01-18 11:45:52 +00:00
Tiezhu Yang
709a3d07f3 gdb: testsuite: print explicit test result for gdb.base/dfp-test.exp
In the current code, if decimal floating point is not supported for
this target, there is no binary file dfp-test, and also there is no
test result after execute the following commands:

  $ make check-gdb TESTS="gdb.base/dfp-test.exp"
  $ grep error gdb/testsuite/gdb.log
  /home/loongson/gdb.git/gdb/testsuite/gdb.base/dfp-test.c:39:1: error: decimal floating point not supported for this target
  [...]
  $ cat gdb/testsuite/gdb.sum
  [...]
  Running target unix
  Running /home/loongson/gdb.git/gdb/testsuite/gdb.base/dfp-test.exp ...

		  === gdb Summary ===
  [...]

With this patch:

  $ make check-gdb TESTS="gdb.base/dfp-test.exp"
  $ cat gdb/testsuite/gdb.sum
  [...]
  Running target unix
  Running /home/loongson/gdb.git/gdb/testsuite/gdb.base/dfp-test.exp ...
  UNSUPPORTED: gdb.base/dfp-test.exp: decimal floating point not supported for this target.

		  === gdb Summary ===

  # of unsupported tests		1
  [...]

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2022-01-18 15:17:57 +08:00
Simon Marchi
0c80c64464 bfd/elf64-ppc.c: fix clang -Wbitwise-instead-of-logical warning in ppc64_elf_check_init_fini
I see this error with clang-14:

      CC       elf64-ppc.lo
    /home/smarchi/src/binutils-gdb/bfd/elf64-ppc.c:13131:11: error: use of bitwise '&' with boolean operands [-Werror,-Wbitwise-instead-of-logical]
      return (check_pasted_section (info, ".init")
             ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Fix by replacing & with &&.  But given that the check_pasted_section
function has side-effects and we want to make sure both calls are made,
assign to temporary variables before evaluating the `&&`.

Change-Id: I849e1b2401bea5f4d8ef3ab9af99ba9e3ef42490
2022-01-17 23:14:57 -05:00
Alan Modra
e2c0149e8b PR28029, debuginfod tests
binutils/NEWS says of the change in --process-links semantics:
  If other debug section display options are also enabled (eg
  --debug-dump=info) then the contents of matching sections in both the main
  file and the separate debuginfo file *will* be displayed.  This is because in
  most cases the debug section will only be present in one of the files.

Implying that debug info is dumped without --process-links.  Indeed
that appears to be the case for readelf.  This does the same for
objdump.

	PR 28029
	* objdump.c (dump_bfd): Do not exit early when !is_mainfile
	&& !processlinks, instead just exclude non-debug output.
	(dump_dwarf): Add is_mainfile parameter and pass to
	dump_dwarf_section.
	(dump_dwarf_section): Only display debug sections when
	!is_mainfile and !process_links.
2022-01-18 11:19:14 +10:30
Alan Modra
48e3e6aec8 Check thin archive element file size against archive header
Makes it a little less likely for someone to break their thin archives.

	* archive.c (_bfd_get_elt_at_filepos): Check thin archive
	element file size.
2022-01-18 11:19:14 +10:30
Alan Modra
e29de63f0d lang_size_relro_segment tidy
This function has seen too many minimal change style edits.
No functional changes in this patch.

	* ldlang.c (lang_size_relro_segment): Tidy.
2022-01-18 11:18:51 +10:30
Alan Modra
1657026ccd PowerPC64 DT_RELR
PowerPC64 takes a more traditional approach to DT_RELR than x86.  Count
relative relocs in check_relocs, allocate space for them and output in
the usual places but not doing so when enable_dt_relr.  DT_RELR is
sized in the existing ppc stub relaxation machinery, run via the
linker's ldemul_after_allocation hook.  DT_RELR is output in the same
function that writes ppc stubs, run via ldemul_finish.

This support should be considered experimental.

bfd/
	* elf64-ppc.c (struct ppc_local_dyn_relocs): Renamed from
	ppc_dyn_relocs.  Add rel_count field.  Update uses.
	(struct ppc_dyn_relocs): New.  Replace all uses of elf_dyn_relocs.
	(struct ppc_link_hash_table): Add relr_alloc, relr_count and
	relr_addr.
	(ppc64_elf_copy_indirect_symbol): Merge rel_count.
	(ppc64_elf_check_relocs): Init rel_count for global and local syms.
	(dec_dynrel_count): Change r_info param to reloc pointer.  Update
	all callers.  Handle decrementing rel_count.
	(allocate_got): Don't allocate space for relative relocs when
	enable_dt_relr.
	(allocate_dynrelocs): Likewise.
	(ppc64_elf_size_dynamic_sections): Likewise.  Handle srelrdyn.
	(ppc_build_one_stub): Don't emit relative relocs on .branch_lt.
	(compare_relr_address, append_relr_off): New functions.
	(got_and_plt_relr_for_local_syms, got_and_plt_relr): Likewise.
	(ppc64_elf_size_stubs): Size .relr.syn.
	(ppc64_elf_build_stubs): Emit .relr.dyn.
	(build_global_entry_stubs_and_plt): Don't output relative relocs
	when enable_dt_relr.
	(write_plt_relocs_for_local_syms): Likewise.
	(ppc64_elf_relocate_section): Likewise.
binutils/
	* testsuite/lib/binutils-common.exp (supports_dt_relr): Add
	powerpc64.
ld/
	* emulparams/elf64ppc.sh: Source dt-relr.sh.
	* testsuite/ld-elf/dt-relr-2b.d: Adjust for powerpc.
	* testsuite/ld-elf/dt-relr-2c.d: Likewise.
	* testsuite/ld-elf/dt-relr-2d.d: Likewise.
	* testsuite/ld-elf/dt-relr-2e.d: Likewise.
2022-01-18 11:18:45 +10:30
Alan Modra
97da0e2677 tweak __ehdr_start visibility and flags for check_relocs
bfd/
	* elf-bfd.h (UNDEFWEAK_NO_DYNAMIC_RELOC): Test linker_def.
ld/
	* ldelf.c (ldelf_before_allocation): Don't force __ehdr_start
	local and hidden here..
	* ldlang.c (lang_symbol_tweaks): ..do so here instead and set
	def_regular and linker_def for check_relocs.  New function
	extracted from lang_process.
2022-01-18 11:18:45 +10:30
GDB Administrator
1f95afb889 Automatic date update in version.in 2022-01-18 00:00:16 +00:00
Nick Clifton
6c037fdbf0 Update the config.guess and config.sub files from the master repository and regenerate files. 2022-01-17 16:21:22 +00:00
Sergey Belyashov
1adce770ea Fix Z80 assembly failure.
PR 28762
	* app.c (do_scrub_chars): Correct handling when the symbol is not 'af'.
2022-01-17 13:00:17 +00:00
Simon Marchi
8bf10e2e77 gdb/infrun: rename variable and move to more specific scope
Move the "started" variable to the scope it's needed, and rename it to
"step_over_started".

Change-Id: I56f3384dbd328f55198063bb855edda10f1492a3
2022-01-17 05:51:41 -05:00
Jan Beulich
ab31da6aff x86: adjust struct instr_info field types
Now that this lives on the stack, let's have it be a little less
wasteful in terms of space. Switch boolean fields to "bool" (also when
this doesn't change their size) and also limit the widths of "rex",
"rex_used", "op_ad", and "op_index". Do a little bit of re-ordering as
well to limit the number of padding holes.
2022-01-17 10:26:43 +01:00
Jan Beulich
71b94817f3 x86: drop index16 field
There's a single use on a generally infrequently taken code path. Put
the necessary conditional there instead.
2022-01-17 10:26:21 +01:00
Jan Beulich
e564475af1 x86: drop most Intel syntax register name arrays
By making use of, in particular, oappend_maybe_intel() there's no need
for this redundant set of static data.
2022-01-17 10:26:01 +01:00
Jan Beulich
e1f9fbb8ad x86: fold variables in memory operand index handling
There's no real need for the pseudo-boolean "haveindex" or for separate
32-bit / 64-bit index pointers. Fold them into a single "indexes" and
set that uniformly to AT&T names, compensating by emitting the register
name via oappend_maybe_intel().
2022-01-17 10:25:40 +01:00
Jan Beulich
2a78304e29 x86: constify disassembler static data
Now that the code is intended to be largely thread-safe, we'd better not
have any writable static objects.
2022-01-17 10:25:08 +01:00
GDB Administrator
45cf0dc2ec Automatic date update in version.in 2022-01-17 00:00:25 +00:00
Joel Brobecker
a3f3402131 gdb/copyright.py: Do not update gdbsupport/Makefile.in
This file is generated, so we should not modify it (any modification
we make is going to be undone at the next re-generation anyway).
2022-01-16 13:50:38 +04:00
GDB Administrator
f61defbc98 Automatic date update in version.in 2022-01-16 00:00:16 +00:00
GDB Administrator
e55d9a1579 Automatic date update in version.in 2022-01-15 00:00:13 +00:00
Simon Marchi
513569fbb7 gdb.dlang/demangle.exp: update expected output for _D8demangle4testFnZv
Since commit ce2d3708bc ("Synchronize binutils libiberty sources with
gcc version."), I see this failure:

    demangle _D8demangle4testFnZv^M
    demangle.test(typeof(null))^M
    (gdb) FAIL: gdb.dlang/demangle.exp: _D8demangle4testFnZv

The commit imported the commit 0e32a5aa8bc9 ("libiberty: Add support for
D `typeof(*null)' types") from the gcc repository.  That commit includes
an update to libiberty/testsuite/d-demangle-expected, which updates a
test for the exact same mangled name:

     _D8demangle4testFnZv
    -demangle.test(none)
    +demangle.test(typeof(null))

I don't know anything about D, but give that the change was made by Iain
Buclaw, the D language maintainer, I trust him on that.

Fix our test by updating the expected output in the same way.

Note: it's not really useful to have all these D demangling tests in the
GDB testsuite, since there are demangling tests in libiberty.  We should
consider removing them, but we first need to make sure that everything
that is covered in gdb/testsuite/gdb.dlang/demangle.exp is also covered
in libiberty/testsuite/d-demangle-expected.

Change-Id: If2b290ea8367b8e1e0b90b20d4a6e0bee517952d
2022-01-14 15:09:32 -05:00
Nils-Christian Kempke
2026dcfcc0 gdb/testsuite: enable __INTEL_LLVM_COMPILER preprocessor in get_compiler_info
Intel Next Gen compiler defines preprocessor __INTEL_LLVM_COMPILER and provides
version info in __clang_version__ e.g. value: 12.0.0 (icx 2020.10.0.1113).

gdb/testsuite/ChangeLog:
2020-12-07  Abdul Basit Ijaz  <abdul.b.ijaz@intel.com>

	* lib/compiler.c: Add Intel next gen compiler pre-processor check.
	* lib/compiler.cc: Ditto.
	* lib/fortran.exp (fortran_main): Check Intel next gen compiler in
	test_compiler_info.
2022-01-14 14:32:29 +00:00
Alan Modra
ff66e8c5be PR28751 mbind2a / mbind2b regressions on powerpc*-linux
include/
	* bfdlink.h (struct bfd_link_info): Add commonpagesize_is_set.
ld/
	PR 28751
	* emultempl/elf.em (handle_option): Set commonpagesize_is_set.
	* ldelf.c (ldelf_after_parse): Don't error when only one of
	-z max-page-size or -z common-page-size is given, correct the
	other value to make it sane.
	* testsuite/ld-elf/elf.exp (mbind2a, mbind2b): Do not pass
	-z max-page-size.
2022-01-14 22:02:23 +10:30
Jan Beulich
fd47eb1a30 x86: drop ymmxmm_mode
This enumerator is not used by any table entry.
2022-01-14 10:56:28 +01:00