Tom de Vries [Thu, 24 Jul 2025 10:06:40 +0000 (12:06 +0200)]
[gdb/testsuite] Add Term::get_string_with_attrs in tuiterm
While reading a gdb.log for test-case gdb.tui/main-2.exp, I noticed that this
line was somewhat hard to read:
...
screen line 6: '<fg:cyan><intensity:bold>|<fg:default><intensity:normal>B+> 21 <reverse:1> return 0;<reverse:0> <fg:cyan><intensity:bold>|<fg:default><intensity:normal>'
...
because of the border attributes.
Then I realized that the test-case is only interested in the text between the
borders, so I added a proc Term::get_string_with_attrs that allows me to drop
the borders, getting us instead:
...
screen line 6: 'B+> 21 <reverse:1> return 0;<reverse:0> '
...
Tom de Vries [Thu, 24 Jul 2025 09:48:29 +0000 (11:48 +0200)]
[gdb/testsuite] Use TERM=ansiw in tuiterm for bsd
TERM=ansi is different on freebsd and linux. Consequently, many TUI
test-cases (gdb.tui/*.exp and gdb.python/tui*.exp) fail on freebsd.
One of the problems is that send_gdb "<cmd>\r\n" is needed instead of
send_gdb "<cmd>\n".
This is because gdb_send "layout regs\n" translates to
"layout regs<KEY_DOWN>", which evidently missing the carriage return part.
While we can work around this, there are other problems. There is no color
support, and the cursor keys fail to scroll the source window.
So I went looking for an alternative to TERM=ansi on freebsd, and came across
TERM=ansiw. Using this didn't work out of the box, but with the fixes in
this series it now does.
I also briefly looked at TERM=ansis, which is interesting because it's
available on both linux and freebsd, but ansiw is a better choice for now.
I've filed PR33179 to document what I learned, with the aim to eventually
follow up and address two test-case failures with TERM=ansis on linux.
Tom de Vries [Thu, 24 Jul 2025 07:18:57 +0000 (09:18 +0200)]
[gdb/testsuite] Log on return in Term::_log_cur
Proc Term::_log_cur logs the cursor update of code in its body argument:
...
proc _ctl_0x08 {} {
_log_cur "Backspace" {
variable _cur_col
if {$_cur_col > 0} {
incr _cur_col -1
}
}
}
...
giving us for instance:
...
+++ Backspace, cursor: (2, 0) -> (2, 0)
...
But if we rewrite the code to use a return:
...
if { $_cur_col == 0 } {
return
}
incr _cur_col -1
...
and the return is triggered, the log message disappears.
Fix this by wrapping the "uplevel $body" in a catch:
...
- uplevel $body
+ set code [catch {uplevel $body} result]
...
Pietro Monteiro [Wed, 23 Jul 2025 23:49:50 +0000 (19:49 -0400)]
gold: configury: fix obsolete macros
Running `autoreconf -vf -Wall' in the gold directory shows errors about the use
of obsolete macros. This patch fix the issues with macros used directly by
configure.ac. However, it doesn't fix all warnings. There are autoconf warnings
about macros from files in config and one automake warning about a target being
shadowed. It cuts a lot of the noise down and makes an upgrade to autoconf
2.71+ easier.
Tom de Vries [Wed, 23 Jul 2025 19:11:41 +0000 (21:11 +0200)]
[gdb/testsuite] Handle auto_left_margin in tuiterm
The terminal capability bw (aka as auto_left_margin) controls whether a
backspace at the start of a line wraps to the last column of the previous
line.
For tuiterm, we use TERM=ansi, and on linux at least that capability is off.
Consequently the current implementation of Term::_ctl_0x08 doesn't wrap.
Add this capability in Term::_ctl_0x08, and add a unit test.
Simon Marchi [Wed, 23 Jul 2025 18:41:42 +0000 (14:41 -0400)]
gdbserver: use reference in range for loop
The armhf buildbot fails to build GDB, with:
../../binutils-gdb/gdbserver/server.cc: In function ‘void handle_general_set(char*)’:
../../binutils-gdb/gdbserver/server.cc:1021:23: error: loop variable ‘<structured bindings>’ creates a copy from type ‘const std::pair<thread_info*, enum_flags<gdb_thread_option> >’ [-Werror=range-loop-construct]
1021 | for (const auto [thread, options] : set_options)
| ^~~~~~~~~~~~~~~~~
../../binutils-gdb/gdbserver/server.cc:1021:23: note: use reference type to prevent copying
1021 | for (const auto [thread, options] : set_options)
| ^~~~~~~~~~~~~~~~~
| &
I did not use a reference on purpose, because the pair is very small. I
don't see the problem when building on amd64, I presume it is because
the pair is considered too big to copy on a 32-bit architecture, but not
on a 64-bit architecture.
Simon Marchi [Wed, 9 Jul 2025 13:17:50 +0000 (09:17 -0400)]
gdb, gdbserver: use structured bindings in a few places
I wanted to change one of these, so I searched for more similar
instances, while at it. I think this looks a bit tidier, over unpacking
the pairs by hand.
Change-Id: Ife4b678f7a6aed01803434197c564d2ab93532a7 Approved-By: Tom Tromey <tom@tromey.com>
Alan Modra [Wed, 23 Jul 2025 12:22:31 +0000 (21:52 +0930)]
PR 33197 [AVR] Incorrect syntax in generated ldscript
Rearrange scripttempl/avr.sc to avoid oddities of shells expanding
${RELOCATING+stuff} in here documents where "stuff" contains quoted
strings. Also I think it is better to avoid multi-line "stuff" as it
can be tricky to spot the ending brace.
Nick Alcock [Thu, 17 Jul 2025 16:45:02 +0000 (17:45 +0100)]
libctf: don't run tests requiring deduplicating linker unless one is in use
Before now, we were relying on gcc -B to repoint GCC at our freshly-built
linker, and assuming we could use this to run tests that do linker dedup.
This is, alas, not reliable (building --with-ld=/an/absolute/path bypasses
-B searches for the linker), and we would like the libctf tests in
particular to not fail if the compiler uses a linker that cannot deduplicate
(simply skipping such tests).
Add a new testsuite function that tries to link one of the lookup tests'
testcases (which is known to produce conflicting types, i.e. a dict with
per-translation-unit children) and then does an objdump and greps it for
signs of the per-translation-unit children. If there are none, the linker
probably just concatenated the sections: i.e., it is not a linker that
can deduplicate CTF.
libctf: exclude always-emitted Solaris symbols from the symtypetab
If we're skipping _BEGIN_ and _END_ we should certainly skip all the other
ABI-required always-emitted symbols given in ld/emultempl/solaris2*em as
well. (This fixes a couple of diagnostics tests, but that's just because
the tests are quite sensitive to CTF section sizes, and introducing any
symtypetab entries for those tests perturbs those.)
Some of these are usually STT_NOTYPE, but not always: if programs already
emitted the symbol they might end up with any type, in particular
STT_OBJECT, and appear in the symtypetabs.
[nca: added commit log, added more symbols]
libctf/
PR libctf/33162
* ctf-serialize.c (ctf_symtab_skippable): Skip
more always-emitted Solaris symbols.
Nick Alcock [Wed, 16 Jul 2025 13:43:25 +0000 (14:43 +0100)]
libctf: get libctf-nobfd.ver from the right place with Solaris ld
We generate de-commented version scripts for Solaris ld (whose
-z gnu-version-script linker option does not support comments),
but after we switched to generating libctf-nobfd.ver itself, we
failed to adjust this code to pick it up from the new location.
Writable mmaps and read are inconsistent with each other on Solaris 11.4,
which breaks archive writing. Simply assert that Solaris 2.11 doesn't have
mmap, falling back to read(): the archive format is being bumped shortly, to
one with completely different writeout code, so this workaround need not
stay for long.
[nca: added commit log]
libctf/
PR libctf/29292
* configure.ac: Turn off mmap on Solaris 2.11.
* configure: Regenerated.
SFrame generation code assumes that since DW_CFA_restore means
restoration of the state of the register to the one at the beginning of
the function, there must be a state to restore to (hence the gas_assert
(cie_fre)).
This assumption needs adjustment. DW_CFA_restore may be present in the
very beginning of a (e.g., cold) function, with no initialized state for
SFrame functions to restore to.
gas/
PR gas/33170
* gas/gen-sframe.c (sframe_xlate_do_restore): Use current FRE if
CIE FRE is not yet setup.
gas/testsuite/
PR gas/33170
* gas/cfi-sframe/cfi-sframe.exp: New test.
* gas/cfi-sframe/cfi-sframe-x86_64-pr33170.d: New test.
* gas/cfi-sframe/cfi-sframe-x86_64-pr33170.s: New test.
Tom de Vries [Tue, 22 Jul 2025 20:26:05 +0000 (22:26 +0200)]
[gdb/cli] Clear line buffer on ^C
Gdb has the ability to gather input over several lines [1], for instance this:
...
(gdb) print 1
$1 = 1
(gdb)
...
can also be typed as:
...
(gdb) print\
1
$2 = 1
(gdb)
...
Furthermore, if we type a command but change our mind, we can abort using ^C
and start over using a fresh gdb prompt [2]:
...
(gdb) print 1❌️ Quit
(gdb) echo 1\n
1
(gdb)
...
Now say we type a multi-line command but abort it, we get:
...
(gdb) print\
1❌️ Quit
(gdb) echo 1\n
❌️ Undefined command: "printecho". Try "help".
(gdb)
...
Using "set trace-commands on", we can see what happened:
...
+printecho 1\n
..
Gdb has prepended the first line of the cancelled multi-line command to the
following command.
Fix this by clearing current_ui->line_buffer on catching a gdb_exception in
start_event_loop.
Tested on x86_64-linux.
Approved-By: Andrew Burgess <aburgess@redhat.com>
PR cli/33063
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33063
gdb: Remove redundant parameter for filename completion
As I was working on an unrelated patch, I noticed that all calls to
make_source_files_completion_list had both parameters of the function
call being the same pointer. I think we can remove that redundancy and
make that call with just one parameter.
ld: Rename a file on Windows fails if target already exists
To rename a file on Windows, the target name cannot exist. Removing file
prior to renaming ensures this is handled.
To remove a file on Windows, the file cannot be open. Closing the bfd
handle ensures this is handled.
Moved call to free on isympp / osympp to after bfd is closed to align
with comment earlier in the cmdline_add_object_only_section function.
Running the standalone test `gdb.reverse` with the target board configuration `unix/-fPIE/-pie` leads to the following failure:
'''
FAIL: gdb.reverse/i386-avx-reverse.exp: verify ymm15 before vbroadcastsd
'''
This happens because the test expects values stored in `dyn_buf0`, but instead (in the test source) the address of the buffer itself
got broadcast to xmm15 (and thus to ymm15).
This happened because the pointer to the start of `dyn_buf0` wasn't dereferenced (see 'vpbroadcast_test' in 'i386-avx-reverse.c'):
'''
asm volatile ("vbroadcastss %0, %%xmm15": : "m" (dyn_buf0));
^
'''
and this consequently lead to the test failing for the next instruction (`vbroadcastsd`), which depended on the correct value being broadcast to the register.
Also, updated the corresponding expected output (gdb.reverse/i386-avx-reverse.exp) to match.
This happens when pie and the input sections, which refers to the global
symbol by got, are all discarded. Since referenced sections are all discarded,
we won't go into relocate_section for those sections, the got entry also won't
be initialized. Therefore, we will get assert fail when adding the RELATIVE
reloc in the finish_dynamic_symbol.
After seeing other target codes, there are two root causes as follows,
1. risc-v may call bfd_elf_link_record_dynamic_symbol in the allocate_dynrelocs
for not only undefweak symbols.
2. risc-v is missing the code to add RELATIVE to R_RISCV_GOT entries in the
relocate_section if a symbol is not dynamic and is not undefined weak under
pic and pie.
If we call bfd_elf_link_record_dynamic_symbol, then the global symbol will be
forced to dynamic, so the h->dynindx will forced to be a number rather than -1,
even it should be -1. Once h->dynindx != -1 and pic/pie, it will go into
finish_dynamic_symbol and insert RELATIVE/64 relocs for the got entry; For the
above case there are two issues,
1. The global symbol _start is forced to be dynamic in the allocate_dynrelocs.
when pie and all the referenced section are discarded, it won't go into
relocate_section to initialize the got entry, so it will cause assert fail
when adding RELATIVE reloc in the finish_dynamic_symbol. The assert fail
represents another problem - if we don't initialize the got entry in the
relocate_section under pie, which means we don't need to go into the
finish_dynamic_symbol and don't need a RELATIVE reloc for the got entry,
it should be NONE reloc.
2. Without linking any discarded section, it originally forces every RELATIVE
relocs added for every got by the finish_dynamic_symbol. Even The final
result looks correct under pie (genearte a RELATIVE reloc for got entry),
not sure if it may cause other problems for some special cases, excpet the
above one.
Therefore, this patch try to fix the above assert fail, and also clarify the
behavior of the allocate_dynrelocs which should only call bfd_elf_link_record_dynamic_symbol
for undefweak symbols, and add the missing code to generate RELATIVE reloc to
R_RISCV_GOT entries in the relocate_section if a symbol is not dynamic and is
not undefined weak under pic and pie.
Passed the gcc/binutils regressions of riscv-gnu-toolchain at least.
Richard Earnshaw [Mon, 21 Jul 2025 15:40:12 +0000 (16:40 +0100)]
aarch64: Use an enum to refer to indices in the opcode table
The indices into the auto-generated tables for opcodes are relatively
unstable. Adding a new opcode can permute the code significantly.
But most of this churn is down to changes in the index values. To
minimize this use enumerated constants. While the index values
change, the enumeration names will need to do so far less often, so
most of the changes in the generated code become localized to the
addition (occasionally removal) of opcodes. This change also makes
the state-change comments unnecessary. The enumeration names contain
the same information (and more), so these are simply deleted.
The enumeration values are placed in a new header file, aarch64-tbl-2.h,
so aarch64-gen gains a new option to build this header and the Makefile
rules are adjusted accordingly.
Richard Earnshaw [Mon, 14 Jul 2025 16:30:01 +0000 (17:30 +0100)]
aarch64: use an enumeration for operand indices.
The generated aarch64 operand tables use index values into an array. But if
the table of operands is modified by inserting a new operand into the middle
of the table, *all* the index values can change, leading to a lot of
churn in the generated output.
include/opcode/aarch64.h already provides an enumeration for the operands,
so make use of that instead of printing out the raw index values.
Richard Earnshaw [Tue, 15 Jul 2025 16:32:20 +0000 (17:32 +0100)]
aarch64: Fix operand name MOPS_WB_Rd -> MOPS_WB_Rn
This field was misnamed in aarch64_opcode_table. It previously didn't
matter too much as the name field only appeared in dumps. But it
doesn't match the enum in include/opcode/aarch64.h and we will shortly
start to rely on that.
These method declarations are unused, remove them. I guess that when
writing a previous patch, changed some free functions to be methods,
then changed my mind, and forgot to remove the declarations.
gprofng ignores functions that are compiled as weak symbols. This
heavily affects C++ class methods that are always compiled by g++
and clang++ as weak symbols. In this case 'gprofng display text'
just displays <static>@ADDRESS(<FILENAME>) instead of proper method
name.
The bug has been introduced in the commit 470a0288a818.
Tom de Vries [Sat, 19 Jul 2025 15:37:01 +0000 (17:37 +0200)]
[gdb/cli] Document \001 and \002 usage for set prompt
PR cli/28887 reports the following problem when using a custom prompt.
First, we set up the custom prompt (with ^ marking the position of the
blinking cursor on the line above):
...
$ gdb -q -ex "set prompt \033[31mgdb$ \033[0m"
gdb$
^
...
Then we type some string, and enter it into the command history:
...
gdb$ some long command
❌️ Undefined command: "some". Try "help".
gdb$
^
...
We use C-p to fetch the previous command:
...
gdb$ some long command
^
...
Sofar, so good.
Finally, we use C-a which should move the cursor to just after the prompt, but
instead we get:
...
gdb$ some long command
^
...
This is fixed by using \001 and \002:
...
(gdb) set prompt \001\033[31m\002gdb$ \001\033[0m\002
...
aka as RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE [1].
Add an example to the documentation showing the use of these markers.
The added example is the equivalent of the "\[\e[0;34m\](gdb)\[\e[0m\]"
example documented at gdb.prompt.substitute_string that can be used with
"set extended-prompt".
While working on this, I noticed that "show prompt" doesn't show back the
original string, using '\e' instead of '\033':
...
gdb$ show prompt
Gdb's prompt is "\001\e[31m\002gdb$ \001\e[0m\002".
...
and that the shown string can't be used as an argument to "set prompt":
...
gdb$ set prompt \001\e[31m\002gdb$ \001\e[0m\002
e[31mgdb$ e[0m
...
I've filed this as PR cli/33184.
Approved-By: Eli Zaretskii <eliz@gnu.org>
[1] https://tiswww.case.edu/php/chet/readline/readline.html
I noticed that the test names in test-case
gdb.base/backtrace-through-cu-nodebug.exp are a bit inconsistent:
...
PASS: $exp: no-cfi: maint frame-unwinder disable ARCH
PASS: $exp: verify no-filters unwind fail without CFI
PASS: $exp: maint flush register-cache
PASS: $exp: verify unwind fail without CFI
PASS: $exp: cfi: maint frame-unwinder disable ARCH
PASS: $exp: Verify unwinding works based only on CFI information
...
There's both a no-cfi prefix, and "without CFI".
Fix this by using proc_with_prefix, getting us a consistent prefix:
...
PASS: $exp: no-cfi: maint frame-unwinder disable ARCH
PASS: $exp: no-cfi: verify no-filters unwind fail
PASS: $exp: no-cfi: maint flush register-cache
PASS: $exp: no-cfi: verify unwind fail
PASS: $exp: cfi: maint frame-unwinder disable ARCH
PASS: $exp: cfi: Verify unwinding works
...
While we're at it, use multi_line to make a regexp more readable.
Tom de Vries [Sat, 19 Jul 2025 15:08:44 +0000 (17:08 +0200)]
[gdb/testsuite] Fix gdb.base/backtrace-through-cu-nodebug.exp without python support
With a gdb build without python support, and test-case
gdb.base/backtrace-through-cu-nodebug.exp I run into:
...
(gdb) bt^M
Required frame unwinder may have been disabled, \
see 'maint info frame-unwinders'^M
(gdb) FAIL: $exp: verify unwind fail without CFI
...
With a gdb build with python support we have instead:
...
(gdb) bt^M
Python Exception <class 'gdb.error'>: \
Required frame unwinder may have been disabled, \
see 'maint info frame-unwinders'^M
(gdb) PASS: $exp: verify unwind fail without CFI
...
but if I change the "bt" into "bt -no-filters" I get the same FAIL and
corresponding output.
So there are two scenarios here.
In the first:
- the bt command is called
- frame #0 is printed
- trying to get the next frame fails and an error is thrown, aborting the
backtrace
- the error is caught and printed
In the second:
- the bt command is called
- the frame filter is applied
- doing so triggers the same error, which is caught and printed by
gdbpy_apply_frame_filter, returning EXT_LANG_BT_NO_FILTERS
- frame #0 is printed
- getting the next frame fails, and the backtrace stops
It seems worthwhile to exercise both scenarios if possible, so add a
"bt -no-filters" test.
Fix the FAIL by updating the regexp to allow both scenarios.
Tom de Vries [Sat, 19 Jul 2025 15:08:44 +0000 (17:08 +0200)]
[gdb/testsuite] Fix gdb.multi/pending-bp.exp without python support
With a gdb build without python support and test-case
gdb.multi/pending-bp.exp, I run into:
...
(gdb) python bp=[b for b in gdb.breakpoints() if b.number == 5][0]^M
Python scripting is not supported in this copy of GDB.^M
(gdb) FAIL: $exp: py_test_toggle_thread: find Python gdb.Breakpoint object
...
Fix this by requiring python support for part of the test-case.
Tom de Vries [Sat, 19 Jul 2025 15:08:44 +0000 (17:08 +0200)]
[gdb/testsuite] Fix gdb.base/break-dbg.exp without xml support
With a gdb build without xml support and test-case gdb.base/break-dbg.exp, I
run into:
...
(gdb) catch syscall^M
warning: Can not parse XML syscalls information; \
XML support was disabled at compile time.^M
Catchpoint 11 (any syscall)^M
(gdb) FAIL: $exp: catch syscall
...
Alan Modra [Thu, 17 Jul 2025 23:56:10 +0000 (09:26 +0930)]
RELOC_AGAINST_DISCARDED_SECTION zero size reloc sections
For some reason the initial implementation (commit 0672748ac053) of
this macro didn't allow discarding of all relocs in a section, perhaps
because doing so would require a testsuite change. This patch allows
zero size relocation sections to result, and adjusts the testsuite.
i386, x86_64, ppc and ppc64 code that avoids a memmove is also changed
to allow zero size reloc sections, and arc fixed to actually adjust
the reloc section header.
Tom de Vries [Fri, 18 Jul 2025 17:51:46 +0000 (19:51 +0200)]
[gdb/testsuite] Fix gdb.arch/amd64-disp-step-self-call.exp on freebsd
On x86_64-freebsd, with test-case gdb.arch/amd64-disp-step-self-call.exp, I
run into:
...
(gdb) continue
Continuing.
Program received signal SIGBUS, Bus error.
Object-specific hardware error.
0x000000080051492c in alarm () from /lib/libc.so.7
(gdb) FAIL: $exp: continue to breakpoint: test_call
...
The behaviour is not specific to gdb, it can be reproduced by running the
test-case executable:
...
$ ./outputs/gdb.arch/amd64-disp-step-self-call/amd64-disp-step-self-call
Bus error (core dumped)
$
...
The bus error happens when executing this instruction in alarm:
... 0000000000093910 <alarm>:
...
9392c: 0f 29 45 d0 movaps %xmm0, -0x30(%rbp)
...
because $rbp is not 16-byte aligned.
This can be fixed by adding the missing frame setup instructions at the start
of main in amd64-disp-step-self-call.S:
...
main:
+ pushq %rbp
+ movq %rsp, %rbp
...
Instead, fix this by moving main from the assembly file to the c file, which
has the same effect.
Also remove the done label, which looks like a copy-past left-over. Instead,
add an unreachable function and use it where appropriate.
Do the same for i386 case (which makes the source files identical for the
amd64 and i386 case, but I decided to leave it like that).
Andrew Burgess [Wed, 16 Jul 2025 14:30:48 +0000 (15:30 +0100)]
gdb/testsuite: mark the start of each gdb.in.* log file
Emit a line in the gdb.log file each time a new gdb.in.NUM command log
is started. The gdb.log line includes the full filename for the new
gdb.in.NUM file.
This change will make it trivial to go from a FAIL in the gdb.log file
to the gdb.in.NUM file that (should) reproduce the failure. When I
encounter a failing test one of my first steps is usually to identify
the gdb.in.NUM file and try re-running it to see if that reproduces
the failure. Some tests create many very similar gdb.in.NUM files, so
finding the exact one can sometimes be difficult. With this patch
that task is now trivial.
There should be no change in what is tested after this commit.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Alan Modra [Thu, 17 Jul 2025 23:54:30 +0000 (09:24 +0930)]
visium: use RELOC_AGAINST_DISCARDED_SECTION
The initial visium support added in commit d924db559be9 didn't make
use of RELOC_AGAINST_DISCARDED_SECTION, and so lacked code to remove
relocations in debug sections.
Tom de Vries [Thu, 17 Jul 2025 20:06:38 +0000 (22:06 +0200)]
[gdb/testsuite] Use pagination_prompt var more often
In some test-cases, matching the pagination prompt is split up to address a
matching race but that's no longer necessary, thanks to commit c3f814a1433
("Fix paginate-*.exp races").
Tom de Vries [Thu, 17 Jul 2025 20:06:38 +0000 (22:06 +0200)]
[gdb/testsuite] Require minimum width in gdb.base/style.exp
In test-case gdb.base/style.exp, we have proc test_pagination_prompt_styling,
which:
- determines a "desired width" by parsing the output of "info files",
- sets width to the "desired width", and
- runs "info files" again.
The "desired width" on my system is 88, but if I override it to 65, I run
into:
...
(gdb) info files^M
Symbols from "^[[32;49;22;27m/data/vries/gdb/leap-15-6/build/gdb/testsuite/outputs/gdb.base/style/style^[[m".^M
--Type <RET> for more, q to quit, c to continue without paging--^M
^MFAIL: gdb.base/style.exp: check pagination prompt styling (timeout)
...
with make target check, and with check-read1 into:
...
(gdb) info files^M
Symbols from "^[[32;49;22;27m/data/vries/gdb/leap-15-6/build/gdb/testsuite/outputs/gdb.base/style/style^[[m".^M
--Type <RET> for more, q to quit, c to continue without paging--^M
^M^[[A^M
Native process:^M
Using the running image of child process 6179.^M
--Type <RET> for more, q to quit, c to continue without paging--ERROR: Window too small.
UNRESOLVED: gdb.base/style.exp: check pagination prompt styling
...
This is caused by the following.
The size of the pagination prompt is 64:
...
1 2 3 4 5 6 1234567890123456789012345678901234567890123456789012345678901234
--Type <RET> for more, q to quit, c to continue without paging--
...
and because we have TERM=ansi and width == 65, readline wraps at 64:
...
(gdb) maint info screen
Number of characters gdb thinks are in a line is 65.
Number of characters readline reports are in a line is 64.
...
In other words, readline wraps when printing the pagination prompt.
This causes some unusual output, and the test is not prepared to handle this.
Fix this by requiring that desired_width is at least
<length of pagination prompt> + 2.
Tested on x86_64-linux.
Approved-By: Andrew Burgess <aburgess@redhat.com>
PR testsuite/33167
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33167
Tom de Vries [Thu, 17 Jul 2025 20:06:38 +0000 (22:06 +0200)]
[gdb/testsuite] Fix regexp in gdb.base/style.exp
In test-case gdb.base/style.exp, we have proc test_pagination_prompt_styling,
which:
- determines a "desired width" by parsing the output of "info files",
- sets width to the "desired width", and
- runs "info files" again.
The "desired width" on my system is 88, but if I override it to 66, I run into:
...
FAIL: gdb.base/style.exp: check pagination prompt styling
...
due to the test classifying this line as a bad line:
...
$hex - $hex is .init_array in --Type <RET> for more, ...
...
This is due to a bug in this regexp:
...
# For lines that don't match this pattern, we cannot comment on
# where the style reset should occur, so lets just claim the line
# is fine.
if { ![regexp "\\s+$::hex - $::hex is \[^\r\n\]+ in " $str] } {
return true
}
...
which is supposed to determine whether the line needs to contain a style
reset.
For aforementioned line, the regexp matches, so the test concludes that the
line should have a style reset, and because it hasn't, it classifies it as a
bad line.
Fix this by making the regexp more strict:
...
if { ![regexp "\\s+$::hex - $::hex is \[^\r\n\]+ in \033" $str] } {
...
Tom de Vries [Thu, 17 Jul 2025 20:06:38 +0000 (22:06 +0200)]
[gdb/testsuite] Stabilize test name in gdb.base/style.exp
With test-case gdb.base/style.exp, I get:
...
PASS: gdb.base/style.exp: set width 88
...
The 88 is not a constant, it's a variable:
...
gdb_test_no_output "set width $desired_width"
...
which is calculated by parsing the output of "info files".
When running with target board unix/-m32, I get instead:
...
PASS: gdb.base/style.exp: set width 67
...
Stabilize the test name by using instead:
...
PASS: gdb.base/style.exp: set width to desired width
...
Marek Pikuła [Wed, 28 May 2025 11:54:47 +0000 (13:54 +0200)]
gdb/risc-v: fix ISA string detection for disassembly
Commit 3f61a38 introduced a regression where the ISA string was no
longer detected based on the ELF header. The mechanism was changed from
directly referencing `abfd` to using `disassembler_info->section`, which
was not properly initialized for RISC-V.
The previous implementation ignored the object in scope, leading to
issues such as failing to decode RVV instructions when a library was
compiled as `rv64gcv` and the main application as `rv64gc`.
This patch resolves both problems by initializing
`disassembler_info->section` with the object currently in scope,
ensuring correct ISA string detection during disassembly.
Sam James [Thu, 17 Jul 2025 12:18:05 +0000 (13:18 +0100)]
binutils: drop unused note_size, contents, old variables
GCC trunk recently had improvements to its -Wunused-but-set-variable which
picked up that contents and hence note_size & old aren't used at all in the
end.
* objcopy.c (merge_gnu_build_notes): Drop unused 'note_size', 'contents',
and 'old' variables.
Alan Modra [Wed, 16 Jul 2025 23:27:11 +0000 (08:57 +0930)]
readelf v850 notes
This patch was prompted by a clang warning:
readelf.c:23317:37: warning: pointer comparison always evaluates to false [-Wtautological-compare]
23317 | || inote.namedata + inote.namesz < inote.namedata)
| ^
Use the same sanity checks as used by process_notes_at. (See commit 5396a86e4396). While we are at it, print all the v850 note info in
one place to properly handle error conditions.
Sam James [Wed, 16 Jul 2025 05:59:14 +0000 (06:59 +0100)]
gas: improve --gsframe documentation
I omitted documentation in 8aad677a12832885acd5be1de8f41e740b8e713d in
error. Rectify that with:
1) changing ---help to mention bare `--gsframe` too, as we're not
getting rid of that;
2) adding the new --gsframe=[no|yes] form to as.texi.
H.J. Lu [Tue, 15 Jul 2025 02:41:25 +0000 (10:41 +0800)]
x86-64: Remove sframe relocs against discarded sections
Since unlike eh_frame editing code, sframe editing code keeps
R_X86_64_NONE reloc as is, its r_offset is wrong, we must not
generate R_X86_64_NONE reloc in sframe section against discarded
sections for "ld -r".
bfd/
PR ld/33156
* elf64-x86-64.c (elf_x86_64_relocate_section): Also remove
sframe relocations against discarded sections for "ld -r".
ld/
PR ld/33156
* testsuite/ld-elf/eh-group.exp (as_gsframe): New.
Assemble eh-group.o with $as_gsframe.
Sam James [Thu, 3 Jul 2025 11:53:22 +0000 (12:53 +0100)]
gas: support --gsframe=no
Being able to explicitly disable SFrames on the command line is useful,
especially when looking at a gas that enables SFrames by default. The
binutils testsuite will benefit from this as there's testcases that don't
expect their presence.
In summary:
* Nothing is passed => no SFrames (no change from before)
* --gsframe is passed => SFrames (no change from before)
* --gsframe=yes is passed => SFrames (previously rejected)
* --gsframe-no is passed => no SFrames (previously rejected)
Sam James [Thu, 3 Jul 2025 11:53:22 +0000 (12:53 +0100)]
gas: support --gsframe=no
Being able to explicitly disable SFrames on the command line is useful,
especially when looking at a gas that enables SFrames by default. The
binutils testsuite will benefit from this as there's testcases that don't
expect their presence.
In summary:
* Nothing is passed => no SFrames (no change from before)
* --gsframe is passed => SFrames (no change from before)
* --gsframe=yes is passed => SFrames (previously rejected)
* --gsframe-no is passed => no SFrames (previously rejected)
H.J. Lu [Sat, 12 Jul 2025 20:56:16 +0000 (04:56 +0800)]
sframe: Allow input R_*_NONE relocations
"ld -r" generates R_*_NONE relocations in sframe section if input
relocations in sframe section are against discarded section. Allow
input R_*_NONE relocations if there are more relocation entries than
SFrame entries, instead of assuming number of SFrame entries == number
of relocation entries.
bfd/
PR ld/33127
* elf-sframe.c (sframe_decoder_init_func_bfdinfo): Allow input
R_*_NONE relocations if there are more relocation entries than
SFrame entries.
ld/
PR ld/33127
* testsuite/ld-x86-64/sframe-reloc-2a.s: New file.
* testsuite/ld-x86-64/sframe-reloc-2b.s: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run PR ld/33127 tests.
Alan Modra [Mon, 14 Jul 2025 09:58:14 +0000 (19:28 +0930)]
gas deferrred diags leak
asan complains when running the gas all/cond-diag test.
* read.c (deferred_diag_head, deferred_diag_tail): Renamed
from deferred_diags and last_deferred_diag, making the tail
pointer a deferred_diag**.
(s_errwarn_if): Simplify appending to list. Free unused diag
on error.
(evaluate_deferred_diags): Free list.
gas: accept leading zeros on dollar local labels in z80 sdcc compat mode
SDCC assembly output uses 5-digit numeric dollar sign labels, padded
with zeros. Commit 226749d made these invalid, and broke the Z80 SDCC
compatibility mode in GAS.
This restores SDCC compatibility by replacing the leading zeros with
spaces when inside dollar local labels and when SDCC compatibility is
enabled. It also restores the SDCC test case to represent actual
syntax emitted by SDCC, and adds a note explaining the purpose of
the test.
H.J. Lu [Sun, 13 Jul 2025 21:21:32 +0000 (05:21 +0800)]
ld: Clear map_head_is_link_order for .gnu_object_only
Clear map_head_is_link_order when generating .gnu_object_only section so
that lang_add_section can add new sections and .sframe sections will be
properly merged by _bfd_elf_merge_section_sframe.
PR ld/33146
* ldlang.c (cmdline_emit_object_only_section): Clear
map_head_is_link_order.
* testsuite/ld-plugin/lto.exp (as_gsframe): New.
(lto_link_tests): Add $as_gsframe to compile lto-4b.o and
lto-4c.o.
Alan Modra [Sun, 13 Jul 2025 23:23:07 +0000 (08:53 +0930)]
Re: gas: Move gas_sframe_check to binutils-common.exp
PR ld/33146
Correct TCL errors trying to access error output file in commit ef7a634dc01d. In fact, get rid of the output file test entirely since
gas exit status is sufficient.
Also there is no need to firstly check for ELF support.
Set check_as_sframe_result, and remove ld-lib.exp check_as_sframe.