Commit Graph

109397 Commits

Author SHA1 Message Date
Nick Alcock
caf606c90d libtool.m4: fix the NM="/nm/over/here -B/option/with/path" case
My previous nm patch handled all cases but one -- if the user set NM in
the environment to a path which contained an option, libtool's nm
detection tries to run nm against a copy of nm with the options in it:
e.g. if NM was set to "nm --blargle", and nm was found in /usr/bin, the
test would try to run "/usr/bin/nm --blargle /usr/bin/nm --blargle".
This is unlikely to be desirable: in this case we should run
"/usr/bin/nm --blargle /usr/bin/nm".

Furthermore, as part of this nm has to detect when the passed-in $NM
contains a path, and in that case avoid doing a path search itself.
This too was thrown off if an option contained something that looked
like a path, e.g. NM="nm -B../prev-gcc"; libtool then tries to run
"nm -B../prev-gcc nm" which rarely works well (and indeed it looks
to see whether that nm exists, finds it doesn't, and wrongly concludes
that nm -p or whatever does not work).

Fix all of these by clipping all options (defined as everything
including and after the first " -") before deciding whether nm
contains a path (but not using the clipped value for anything else),
and then removing all options from the path-modified nm before
looking to see whether that nm existed.

NM=my-nm now does a path search and runs e.g.
  /usr/bin/my-nm -B /usr/bin/my-nm

NM=/usr/bin/my-nm now avoids a path search and runs e.g.
  /usr/bin/my-nm -B /usr/bin/my-nm

NM="my-nm -p../wombat" now does a path search and runs e.g.
  /usr/bin/my-nm -p../wombat -B /usr/bin/my-nm

NM="../prev-binutils/new-nm -B../prev-gcc" now avoids a path search:
  ../prev-binutils/my-nm -B../prev-gcc -B ../prev-binutils/my-nm

This seems to be all combinations, including those used by GCC bootstrap
(which, before this commit, fails to bootstrap when configured
--with-build-config=bootstrap-lto, because the lto plugin is now using
--export-symbols-regex, which requires libtool to find a working nm,
while also using -B../prev-gcc to point at the lto plugin associated
with the GCC just built.)

Regenerate all affected configure scripts.

	* libtool.m4 (LT_PATH_NM): Handle user-specified NM with
	options, including options containing paths.
2022-03-25 12:02:35 +00:00
Alan Modra
ee41183df4 Re: gas/Dwarf: improve debug info generation from .irp and alike blocks
am33_2.0-linux is a mn10300 target.

	* testsuite/gas/elf/dwarf-5-irp.d: xfail am33.
2022-03-25 11:35:19 +10:30
GDB Administrator
891172d1d4 Automatic date update in version.in 2022-03-25 00:00:07 +00:00
Aaron Merey
b0e0d830d9 Remove download size from debuginfod progress messages if unavailable
Currently debuginfod progress update messages include the size of
each download:

  Downloading 7.5 MB separate debug info for /lib/libxyz.so.0

This value originates from the Content-Length HTTP header of the
transfer.  However this header is not guaranteed to be present for
each download.  This can happen when debuginfod servers compress files
on-the-fly at the time of transfer.  In this case gdb wrongly prints
"-0.00 MB" as the size.

This patch removes download sizes from progress messages when they are
not available.  It also removes usage of the progress bar until
a more thorough reworking of progress updating is implemented. [1]

[1] https://sourceware.org/pipermail/gdb-patches/2022-February/185798.html
2022-03-24 14:51:22 -04:00
Reuben Thomas
8bd59ec1bb sim: fix a comment typo in sim-load.c
Fix a typo where the documentation refers to a function parameter by the
wrong name.

Change-Id: I99494efe62cd4aa76fb78a0bd5da438d35740ebe
2022-03-24 13:28:50 -04:00
Reuben Thomas
c41524681b sim: fix “alligned” typos
Change-Id: Ifd574e38524dd4f1cf0fc003e0c5c7499abc84a0
2022-03-24 10:34:51 -04:00
Jan Beulich
f1a4558586 x86: mention dropped L1OM/K1OM support in ld/ as well
This amends e961c696dc ("x86: drop L1OM/K1OM support from ld"). Also
remove the marker that I mistakenly added in c085ab00c7 ("x86: drop
L1OM/K1OM support from gas").
2022-03-24 15:27:28 +01:00
Simon Marchi
ba7789a316 gdb/testsuite: remove gdb.python/pretty-print-call-by-hand.exp
This test was added without a corresponding fix, with some setup_kfails.
However, it results in UNRESOLVED results when GDB is built with ASan.

  ERROR: GDB process no longer exists
  GDB process exited with wait status 1946871 exp7 0 1
  UNRESOLVED: gdb.python/pretty-print-call-by-hand.exp: frame print: backtrace test (PRMS gdb/28856)

Remove the test from the tree, I'll attach it to the Bugzilla bug
instead [1].

[1] https://sourceware.org/bugzilla/show_bug.cgi?id=28856

Change-Id: Id95d8949fb8742874bd12aeac758aa4d7564d678
2022-03-24 10:21:10 -04:00
Jan Beulich
e961c696dc x86: drop L1OM/K1OM support from ld
This was only rudimentary support anyway; none of the sub-architecture
specific insns were ever supported.
2022-03-24 09:38:55 +01:00
Jan Beulich
526ca202fc x86: drop L1OM special case from disassembler
There wasn't any real support anyway: None of the sub-architecture
specific insns were ever supported.
2022-03-24 09:38:19 +01:00
Jan Beulich
ed084cdcc8 MAINTAINERS: add myself
I much appreciate Nick offering this role to me. Nevertheless there's
still a lot for me to learn here.

At this occasion also update my email address in the pre-existing, much
more narrow entry.
2022-03-24 09:35:56 +01:00
GDB Administrator
21152986f1 Automatic date update in version.in 2022-03-24 00:00:07 +00:00
Andrew Burgess
b24ae11cd4 gdb/testsuite: address test failures in gdb.mi/mi-multi-commands.exp
The gdb.mi/mi-multi-commands.exp test was added in commit:

  commit d08cbc5d32
  Date:   Wed Dec 22 12:57:44 2021 +0000

      gdb: unbuffer all input streams when not using readline

And then tweaked in commit:

  commit 144459531d
  Date:   Mon Feb 7 20:35:58 2022 +0000

      gdb/testsuite: relax pattern in new gdb.mi/mi-multi-commands.exp test

The second of these commits was intended to address periodic test
failures that I was seeing, and this change did fix some problems,
but, unfortunately, introduced other issues.

The problem is that the test relies on sending two commands to GDB in
a single write.  As the characters that make these two commands arrive
they are echoed to GDB's console.  However, there is a race between
how quickly the characters are echoed and how quickly GDB decides to
act on the incoming commands.

Usually, both commands are echoed in full before GDB acts on the first
command, but sometimes this is not the case, and GDB can execute the
first command before both commands are fully echoed to the console.
In this case, the output of the first command will be mixed in with
the echoing of the second command.

This mixing of the command echoing and the first command output is
what was causing failures in the original version of the test.

The second commit relaxed the expected output pattern a little, but
was still susceptible to failures, so this commit further relaxes the
pattern.

Now, we look for the first command output with no regard to what is
before, or after the command.  Then we look for the first mi prompt to
indicate that the first command has completed.

I believe that this change should make the test more stable than it
was before.
2022-03-23 14:47:35 +00:00
Nick Alcock
faf5e6ace8 libctf: add LIBCTF_WRITE_FOREIGN_ENDIAN debugging option
libctf has always handled endianness differences by detecting
foreign-endian CTF dicts on the input and endian-flipping them: dicts
are always written in native endianness.  This makes endian-awareness
very low overhead, but it means that the foreign-endian code paths
almost never get routinely tested, since "make check" usually reads in
dicts ld has just written out: only a few corrupted-CTF tests are
actually in fixed endianness, and even they only test the foreign-
endian code paths when you run make check on a big-endian machine.
(And the fix is surely not to add more .s-based tests like that, because
they are a nightmare to maintain compared to the C-code-based ones.)

To improve on this, add a new environment variable,
LIBCTF_WRITE_FOREIGN_ENDIAN, which causes libctf to unconditionally
endian-flip at ctf_write time, so the output is always in the wrong
endianness.  This then tests the foreign-endian read paths properly
at open time.

Make this easier by restructuring the writeout code in ctf-serialize.c,
which duplicates the maybe-gzip-and-write-out code three times (once
for ctf_write_mem, with thresholding, and once each for
ctf_compress_write and ctf_write just so those can avoid thresholding
and/or compression).  Instead, have the latter two call the former
with thresholds of 0 or (size_t) -1, respectively.

The endian-flipping code itself gains a bit of complexity, because
one single endian-flipper (flip_types) was assuming the input to be
in foreign-endian form and assuming it could pull things out of the
input once they had been flipped and make sense of them. At the
cost of a few lines of duplicated initializations, teach it to
read before flipping if we're flipping to foreign-endianness instead
of away from it.

libctf/
	* ctf-impl.h (ctf_flip_header): No longer static.
	(ctf_flip): Likewise.
	* ctf-open.c (flip_header): Rename to...
	(ctf_flip_header): ... this, now it is not private to one file.
	(flip_ctf): Rename...
	(ctf_flip): ... this too.  Add FOREIGN_ENDIAN arg.
	(flip_types): Likewise.  Use it.
	(ctf_bufopen_internal): Adjust calls.
	* ctf-serialize.c (ctf_write_mem): Add flip_endian path via
	a newly-allocated bounce buffer.
	(ctf_compress_write): Move below ctf_write_mem and reimplement
	in terms of it.
	(ctf_write): Likewise.
	(ctf_gzwrite): Note that this obscure writeout function does not
	support endian-flipping.
2022-03-23 13:48:32 +00:00
Nick Alcock
84f5c557a4 libctf, ld: diagnose corrupted CTF header cth_strlen
The last section in a CTF dict is the string table, at an offset
represented by the cth_stroff header field.  Its length is recorded in
the next field, cth_strlen, and the two added together are taken as the
size of the CTF dict.  Upon opening a dict, we check that none of the
header offsets exceed this size, and we check when uncompressing a
compressed dict that the result of the uncompression is the same length:
but CTF dicts need not be compressed, and short ones are not.
Uncompressed dicts just use the ctf_size without checking it.  This
field is thankfully almost unused: it is mostly used when reserializing
a dict, which can't be done to dicts read off disk since they're
read-only.

However, when opening an uncompressed foreign-endian dict we have to
copy it out of the mmaped region it is stored in so we can endian-
swap it, and we use ctf_size when doing that.  When the cth_strlen is
corrupt, this can overrun.

Fix this by checking the ctf_size in all uncompressed cases, just as we
already do in the compressed case.  Add a new test.

This came to light because various corrupted-CTF raw-asm tests had an
incorrect cth_strlen: fix all of them so they produce the expected
error again.

libctf/
	PR libctf/28933
	* ctf-open.c (ctf_bufopen_internal): Always check uncompressed
	CTF dict sizes against the section size in case the cth_strlen is
	corrupt.

ld/
	PR libctf/28933
	* testsuite/ld-ctf/diag-strlen-invalid.*: New test,
	derived from diag-cttname-invalid.s.
	* testsuite/ld-ctf/diag-cttname-invalid.s: Fix incorrect cth_strlen.
	* testsuite/ld-ctf/diag-cttname-null.s: Likewise.
	* testsuite/ld-ctf/diag-cuname.s: Likewise.
	* testsuite/ld-ctf/diag-parlabel.s: Likewise.
	* testsuite/ld-ctf/diag-parname.s: Likewise.
2022-03-23 13:48:32 +00:00
Nick Alcock
203bfa2f6b include, libctf, ld: extend variable section to contain functions too
The CTF variable section is an optional (usually-not-present) section in
the CTF dict which contains name -> type mappings corresponding to data
symbols that are present in the linker input but not in the output
symbol table: the idea is that programs that use their own symbol-
resolution mechanisms can use this section to look up the types of
symbols they have found using their own mechanism.

Because these removed symbols (mostly static variables, functions, etc)
all have names that are unlikely to appear in the ELF symtab and because
very few programs have their own symbol-resolution mechanisms, a special
linker flag (--ctf-variables) is needed to emit this section.

Historically, we emitted only removed data symbols into the variable
section.  This seemed to make sense at the time, but in hindsight it
really doesn't: functions are symbols too, and a C program can look them
up just like any other type.  So extend the variable section so that it
contains all static function symbols too (if it is emitted at all), with
types of kind CTF_K_FUNCTION.

This is a little fiddly.  We relied on compiler assistance for data
symbols: the compiler simply emits all data symbols twice, once into the
symtypetab as an indexed symbol and once into the variable section.

Rather than wait for a suitably adjusted compiler that does the same for
function symbols, we can pluck unreported function symbols out of the
symtab and add them to the variable section ourselves.  While we're at
it, we do the same with data symbols: this is redundant right now
because the compiler does it, but it costs very little time and lets the
compiler drop this kludge and save a little space in .o files.

include/
	* ctf.h: Mention the new things we can see in the variable
	section.

ld/
	* testsuite/ld-ctf/data-func-conflicted-vars.d: New test.

libctf/
	* ctf-link.c (ctf_link_deduplicating_variables): Duplicate
	symbols into the variable section too.
	* ctf-serialize.c (symtypetab_delete_nonstatic_vars): Rename
	to...
	(symtypetab_delete_nonstatics): ... this.  Check the funchash
	when pruning redundant variables.
	(ctf_symtypetab_sect_sizes): Adjust accordingly.
	* NEWS: Describe this change.
2022-03-23 13:48:32 +00:00
Nick Alcock
a12c988767 ld, testsuite: improve CTF-availability test
The test for -gctf support in the compiler is used to determine when to
run the ld-ctf tests and most of those in libctf.  Unfortunately,
because it uses check_compiler_available and compile_one_cc, it will
fail whenever the compiler emits anything on stderr, even if it
actually does support CTF perfectly well.

So, instead, ask the compiler to emit assembler output and grep it for
references to ".ctf": this is highly unlikely to be present if the
compiler does not support CTF.  (This will need adjusting when CTF grows
support for non-ELF platforms that don't dot-prepend their section
names, but right now the linker doesn't link CTF on any such platforms
in any case.)

With this in place we can do things like run all the libctf tests under
leak sanitizers etc even if those spray warnings on simple CTF
compilations, rather than being blocked from doing so just when we would
most like to.

ld/
	* testsuite/lib/ld-lib.exp (check_ctf_available): detect CTF
	even if a CTF-capable compiler emits warnings.
2022-03-23 13:38:16 +00:00
Simon Marchi
5aee458796 gdb/python: remove Python 2/3 compatibility macros
New in this version:

 - Rebase on master, fix a few more issues that appeared.

python-internal.h contains a number of macros that helped make the code
work with both Python 2 and 3.  Remove them and adjust the code to use
the Python 3 functions.

Change-Id: I99a3d80067fb2d65de4f69f6473ba6ffd16efb2d
2022-03-23 07:42:57 -04:00
Simon Marchi
edae3fd660 gdb/python: remove Python 2 support
New in this version:

 - Add a PY_MAJOR_VERSION check in configure.ac / AC_TRY_LIBPYTHON.  If
   the user passes --with-python=python2, this will cause a configure
   failure saying that GDB only supports Python 3.

Support for Python 2 is a maintenance burden for any patches touching
Python support.  Among others, the differences between Python 2 and 3
string and integer types are subtle.  It requires a lot of effort and
thinking to get something that behaves correctly on both.  And that's if
the author and reviewer of the patch even remember to test with Python
2.

See this thread for an example:

  https://sourceware.org/pipermail/gdb-patches/2021-December/184260.html

So, remove Python 2 support.  Update the documentation to state that GDB
can be built against Python 3 (as opposed to Python 2 or 3).

Update all the spots that use:

 - sys.version_info
 - IS_PY3K
 - PY_MAJOR_VERSION
 - gdb_py_is_py3k

... to only keep the Python 3 portions and drop the use of some
now-removed compatibility macros.

I did not update the configure script more than just removing the
explicit references to Python 2.  We could maybe do more there, like
check the Python version and reject it if that version is not
supported.  Otherwise (with this patch), things will only fail at
compile time, so it won't really be clear to the user that they are
trying to use an unsupported Python version.  But I'm a bit lost in the
configure code that checks for Python, so I kept that for later.

Change-Id: I75b0f79c148afbe3c07ac664cfa9cade052c0c62
2022-03-23 07:41:19 -04:00
Jan Beulich
e52a16f2aa x86: reject relocations involving registers
To prevent fatal or even internal errors, add a simple check to
i386_validate_fix(), rejecting relocations when their target symbol is
an equate of a register (or resolved to reg_section for any other
reason).
2022-03-23 12:31:29 +01:00
Jan Beulich
64d23078e3 x86: improve resolution of register equates
Allow transitive (or recursive) equates to work in addition to direct
ones. The only requirements are that
- the equate being straight of a register, i.e. no expressions involved
  (albeit I'm afraid something like "%eax + 0" will be viewed as %eax),
- at the point of use there's no forward ref left which cannot be
  resolved, yet.
2022-03-23 12:31:04 +01:00
Jan Beulich
3b55a1d00a Revert "PR28977 tc-i386.c internal error in parse_register"
This reverts commit 5fac3f02ed,
which was superceeded / replaced by 4faaa10f3f.
2022-03-23 12:29:39 +01:00
Jan Beulich
4faaa10f3f x86: don't attempt to resolve equates and alike from i386_parse_name()
PR gas/28977

Perhaps right from its introduction in 4d1bb7955a it was wrong for
i386_parse_name() to call parse_register(). This being a hook from the
expression parser, it shouldn't be resolving e.g. equated symbols.
That's relevant only for all other callers of parse_register().

To compensate, in Intel syntax mode check_register() needs calling;
perhaps not doing so was an oversight right when the function was
introduced. This is necessary in particular to force EVEX encoding when
VRex registers are used (but of course also to reject bad uses of
registers, i.e. fully matching what parse_register() needs it for).
2022-03-23 12:28:53 +01:00
Luis Machado
131a355fbc Update the list of recognized m-profile TAG_CPU_ARCH_*
Check 3 additional variants previously not recognized:

- TAG_CPU_ARCH_V7E_M
- TAG_CPU_ARCH_V8M_BASE
- TAG_CPU_ARCH_V8M_MAIN
2022-03-23 10:54:18 +00:00
Jan Beulich
1740425885 gas/Dwarf5: re-use file 0 line string table entry when faking file 0
No need to emit the same string a 2nd time for file 1 in this case.
2022-03-23 08:48:24 +01:00
Jan Beulich
8728bc3d87 gas/Dwarf5: adjust .debug_line file 0 checking
First of all when a table entry has a NULL filename, the two inner if()s
are better done the other way around: The 2nd doesn't depend on what the
first does. This then renders redundant half of the conditions of the
other if() and clarifies that subsequently only entry 0 is dealt with
(indicating that part of the comment was wrong). Finally for there to be
a usable name in slot 1, files_in_use needs to be larger than 1 and slot
1's (rather than slot 0's) name needs to be non-NULL.
2022-03-23 08:48:02 +01:00
Jan Beulich
47513fab28 gas/Dwarf5: drop dead code
Commit 3417bfca67 ("GAS: DWARF-5: Ensure that the 0'th entry in the
directory table contains the current... ") added a "dwarf_level < 5"
check to out_dir_and_file_list(). This rendered dead that branch of the
construct, due to the enclosing if()'s "DWARF2_LINE_VERSION >= 5".
Delete that code as well as the corresponding part of the comment.

While there also drop a redundant "dirs != NULL": "dirs" will always be
non-NULL when dirs_in_use is not zero.
2022-03-23 08:47:41 +01:00
Jan Beulich
7992631e8c gas/Dwarf: improve debug info generation from .irp and alike blocks
Tying the bumping of the logical line number to reading from the
original source file looks wrong: Upon finishing of the processing of an
sb the original values will be restored anyway. Yet without bumping the
line counter uses of .line inside e.g. an .irp construct won't have the
intended effect: Such uses may be necessary to ensure proper debug info
is emitted in particular when switching sections inside the .irp body,
as dwarf2_gen_line_info() would bail without doing anything when it
finds the line number unchanged from what it saw last.
2022-03-23 08:46:39 +01:00
Jan Beulich
36e2d65d26 ELF32: don't silently truncate relocation addends
At least x86-64's x32 sub-mode and RISC-V's 32-bit mode calculate
addends as 64-bit values, but store them in signed 32-bit fields when
generating the file without encountering any earlier error. When the
relocated field is a 64-bit one, the value resulting after processing
the relocation record when linking (or the latest when loading) may
thus be wrong due to the truncation.

With the code change in place, one x32 testcase actually triggers the
new diagnostic. That one case of too large a (negative) addend is being
adjusted alongside the addition of a new testcase to actually trigger
the new error. (Note that due to internal BFD behavior the relocation in
.data doesn't get processed anymore after the errors in .text.)

Note that in principle it is possible to express 64-bit relocations in
ELF32, but this would require .rel relocations, i.e. with the addend
stored in the 64-bit field being relocated. But I guess it would be a
lot of effort for little gain to actually support this.
2022-03-23 08:43:13 +01:00
Jan Beulich
b3446f947b gas: retain whitespace between strings
Macro arguments may be separated by commas or just whitespace. Macro
arguments may also be quoted (where one level of quotes is removed in
the course of determining the values for the respective formal
parameters). Furthermore this quote removal knows _two_ somewhat odd
escaping mechanisms: One, apparently in existence forever, is that a
pair of quotes counts as the escaping of a quote, with the pair being
transformed to a single quote in the course of quote removal. The other
(introduced by c06ae4f232) looks more usual on the surface in that it
deals with \" sequences, but it _retains_ the escaping \. Hence only the
former mechanism is suitable when the value to be used by the macro body
is to contain a quote. Yet this results in ambiguity of what "a""b" is
intended to mean; elsewhere (e.g. for .ascii) it represents two
successive string literals. However, in any event is the above different
from "a" "b": I don't think this can be viewed the same as "a""b" when
processing macro arguments.

Change the scrubber to retain such whitespace, by making the processing
of strings more similar to that of symbols. And indeed this appears to
make sense when taking into account that for quite a while gas has been
supporting quoted symbol names.

Taking a more general view, however, the change doesn't go quite far
enough. There are further cases where significant whitespace is removed
by the scrubber. The new testcase enumerates a few in its ".if 0"
section. I'm afraid the only way that I see to deal with this would be
to significantly simplify the scrubber, such that it wouldn't do much
more than collapse sequences of unquoted whitespace into a single blank.
To be honest problems in this area aren't really surprising when seeing
that there's hardly any checking of .macro use throughout the testsuite
(and in particular in the [relatively] generic tests under all/).
2022-03-23 08:41:54 +01:00
Vladimir Mezentsev
b8466ab5e5 Only .so files are used in libcollector. Remove the other files.
* libcollector/Makefile.am (install-data-local): Remove the *.la
	and *.a libraries.
	* libcollector/Makefile.in: Regenerate.
2022-03-23 16:00:10 +10:30
Tiezhu Yang
f629ad7dac gdb: testsuite: use gdb_attach to fix jit-elf.exp
If /proc/sys/kernel/yama/ptrace_scope is 1, when execute the following
command without superuser:

  make check-gdb TESTS="gdb.base/jit-elf.exp"

we can see the following messages in gdb/testsuite/gdb.log:

  (gdb) attach 1650108
  Attaching to program: /home/yangtiezhu/build/gdb/testsuite/outputs/gdb.base/jit-elf/jit-elf-main, process 1650108
  ptrace: Operation not permitted.
  (gdb) FAIL: gdb.base/jit-elf.exp: attach: one_jit_test-2: break here 1: attach

use gdb_attach to fix the above issue, at the same time, the clean_reattach
proc should return a value to indicate whether it worked, and the callers
should return early as well on failure.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2022-03-23 11:56:46 +08:00
Tiezhu Yang
5b5442fbf0 gdb: testsuite: use gdb_attach to fix attach-pie-noexec.exp
If /proc/sys/kernel/yama/ptrace_scope is 1, when execute the following
command without superuser:

  make check-gdb TESTS="gdb.base/attach-pie-noexec.exp"

we can see the following messages in gdb/testsuite/gdb.log:

  (gdb) attach 6500
  Attaching to process 6500
  ptrace: Operation not permitted.
  (gdb) PASS: gdb.base/attach-pie-noexec.exp: attach

It is obviously wrong, the expected result should be UNSUPPORTED in such
a case.

With this patch, we can see "Operation not permitted" in the log info,
and then we can do the following processes to test:
(1) set ptrace_scope as 0
    $ echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
    $ make check-gdb TESTS="gdb.base/attach-pie-noexec.exp"
(2) use sudo
    $ sudo make check-gdb TESTS="gdb.base/attach-pie-noexec.exp"

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2022-03-23 11:56:42 +08:00
Tiezhu Yang
a7e6a19e87 gdb: testsuite: add new gdb_attach to check "attach" command
This commit adds new gdb_attach to centralize the failure checking of
"attach" command. Return 0 if attach failed, otherwise return 1.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2022-03-23 11:56:38 +08:00
Tiezhu Yang
11c19d73c3 gdb: testsuite: remove attach test from can_spawn_for_attach
As Pedro Alves said, caching procs should not issue pass/fail [1],
this commit removes attach test from can_spawn_for_attach, at the
same time, use "verbose -log" instead of "unsupported" to get a
trace about why a test run doesn't support spawning for attach.

[1] https://sourceware.org/pipermail/gdb-patches/2022-March/186311.html

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2022-03-23 11:56:34 +08:00
GDB Administrator
9457d59e9d Automatic date update in version.in 2022-03-23 00:00:08 +00:00
John Baldwin
065a00b3a4 Add support for hardware breakpoints/watchpoints on FreeBSD/Aarch64.
This shares aarch64-nat.c and nat/aarch64-hw-point.c with the Linux
native target.  Since FreeBSD writes all of the debug registers in one
ptrace op, use an unordered_set<> to track the "dirty" state for
threads rather than bitmasks of modified registers.
2022-03-22 12:05:43 -07:00
John Baldwin
a3627b5428 fbsd-nat: Add a low_prepare_to_resume virtual method.
This method can be overridden by architecture-specific targets to
perform additional work before a thread is resumed.
2022-03-22 12:05:43 -07:00
John Baldwin
983b1119bc fbsd-nat: Add a low_delete_thread virtual method.
This method can be overridden by architecture-specific targets to
perform additional work when a thread is deleted.

Note that this method is only invoked on systems supporting LWP
events, but the pending use case (aarch64 debug registers) is not
supported on older kernels that do not support LWP events.
2022-03-22 12:05:43 -07:00
John Baldwin
6719bc690e fbsd-nat: Add helper routine to fetch siginfo_t for a ptid. 2022-03-22 12:05:43 -07:00
John Baldwin
1570c37c34 aarch64: Add an aarch64_nat_target mixin class.
This class includes platform-independent target methods for hardware
breakpoints and watchpoints using routines from
nat/aarch64-hw-point.c.

stopped_data_address is not platform-independent since the FAR
register holding the address for a breakpoint hit must be fetched in a
platform-specific manner.  However, aarch64_stopped_data_address is
provided as a helper routine which performs platform-independent
validation given the value of the FAR register.

For tracking the per-process debug register mirror state, use an
unordered_map indexed by pid as recently adopted in x86-nat.c rather
than a manual linked-list.
2022-03-22 12:05:43 -07:00
John Baldwin
4bd817e71e nat: Split out platform-independent aarch64 debug register support.
Move non-Linux-specific support for hardware break/watchpoints from
nat/aarch64-linux-hw-point.c to nat/aarch64-hw-point.c.  Changes
beyond a simple split of the code are:

- aarch64_linux_region_ok_for_watchpoint and
  aarch64_linux_any_set_debug_regs_state renamed to drop linux_ as
  they are not platform specific.

- Platforms must implement the aarch64_notify_debug_reg_change
  function which is invoked from the platform-independent code when a
  debug register changes for a given debug register state.  This does
  not use the indirection of a 'low' structure as is done for x86.

- The handling for kernel_supports_any_contiguous_range is not
  pristine.  For non-Linux it is simply defined to true.  Some uses of
  this could perhaps be implemented as new 'low' routines for the
  various places that check it instead?

- Pass down ptid into aarch64_handle_breakpoint and
  aarch64_handle_watchpoint rather than using current_lwp_ptid which
  is only defined on Linux.  In addition, pass the ptid on to
  aarch64_notify_debug_reg_change instead of the unused state
  argument.
2022-03-22 12:05:43 -07:00
John Baldwin
041a4212d3 x86-fbsd-nat: Copy debug register state on fork.
Use the FreeBSD native target low_new_fork hook to copy the
per-process debug state from the parent to the child on fork.
2022-03-22 12:05:43 -07:00
John Baldwin
c77282d8ba fbsd-nat: Add a low_new_fork virtual method.
This method can be overridden by architecture-specific targets to
perform additional work when a new child process is forked.
2022-03-22 12:05:43 -07:00
John Baldwin
a49ce729c8 Add an x86_fbsd_nat_target mixin class for FreeBSD x86 native targets.
This class implements debug register support common between the i386
and amd64 native targets.

While here, remove #ifdef's for HAVE_PT_GETDBREGS in FreeBSD-specific
code.  The ptrace request has been present on FreeBSD x86
architectures since 4.0 (released in March 2000).  The last FreeBSD
release without this support is 3.5 released in June 2000.
2022-03-22 12:05:43 -07:00
John Baldwin
b1babce7c3 x86-nat: Add x86_lookup_debug_reg_state.
This function returns nullptr if debug register state does not yet
exist for a given process rather than creating new state.
2022-03-22 12:05:43 -07:00
John Baldwin
922c2fc18e x86-nat: Use an unordered_map to store per-pid debug reg state.
This replaces a manual linked list which used O(n) lookup and removal.
2022-03-22 12:05:43 -07:00
John Baldwin
711b0b6698 Remove USE_SIGTRAP_SIGINFO condition for FreeBSD/x86 debug regs support.
For BSD x86 targets, stopped_by_hw_breakpoint doesn't check siginfo_t
but inspects the DR6 register directly via PT_GETDBREGS.
2022-03-22 12:05:43 -07:00
Tom Tromey
de8fd80cf9 Remove two unused variables
I found a couple of spots that declare a symtab_and_line but don't
actually use it.  I think this probably isn't detected as unused
because it has a constructor.
2022-03-22 11:20:28 -06:00
Steiner H Gunderson
86ed2a5eae Fix return code in _bfd_dwarf2_find_nearest_line().
* dwarf2.c (_bfd_dwarf2_find_nearest_line): if a function name is
	found, but no line number info, then return a result of 2.
2022-03-22 15:32:32 +00:00