Commit Graph

123852 Commits

Author SHA1 Message Date
GDB Administrator
e60bd80314 Automatic date update in version.in 2025-10-13 00:00:07 +00:00
Andrew Burgess
20a08d9851 gdb/remote: replace use of std::pair with an actual struct
Commit:

  commit 5edcbe2277
  Date:   Mon Jul 24 17:35:54 2023 +0100

      gdb: detect when gdbserver has no default executable set

Introduced a use of std::pair as a data structure to hold some per
program space information within the program space registry.

It was pointed out during review of a later patch[1][2] that the code
would be easier to understand if the std::pair was replaced with a
struct with named fields.

That is what this commit does.  Replace the std::pair with a struct,
and update all accesses to use the named fields.

There should be no user visible changes after this commit.

[1] https://inbox.sourceware.org/gdb-patches/69681489-d556-4496-9e3b-8273cab3d8f5@simark.ca
[2] https://inbox.sourceware.org/gdb-patches/469655a7-2bcc-4f27-b2d7-3fa8808ca5b5@simark.ca

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-10-12 13:46:12 +01:00
GDB Administrator
def8befb9d Automatic date update in version.in 2025-10-12 00:00:06 +00:00
Tom Tromey
906678d08e Return references from compunit_symtab iterator
This changes the compunit_symtab iterator to return references rather
than pointers, following the style of some other recent changes.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-10-11 13:40:32 -06:00
Tom Tromey
61a98786bf Use std::unique_ptr in compunit_symtab
Now that compunit_symtab can have a destructor, it can use
std::unique_ptr rather than an explicit 'delete'.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-10-11 13:27:36 -06:00
Tom Tromey
23e3008c3e Allocate compunit_symtab on heap
This patch changes compunit_symtab to be allocated on the heap, using
'new'.  It also changes the container that holds these in the objfile.
I chose to use an intrusive_list to store compunit_symtab because I
think pointer stability is needed here.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33435
Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-10-11 13:27:10 -06:00
Simon Marchi
6b0581fc92 gdb/symtab: remove section parameter from find_function_start_sal
All 2 callers of this overload pass NULL.  Remove the parameter and pass
nullptr explicitly to find_function_start_sal_1.

Change-Id: Ie20e7c8ad980cd7af99b6ba9c23f4da19febc1bc
2025-10-11 00:04:09 -04:00
GDB Administrator
e3da6edc98 Automatic date update in version.in 2025-10-11 00:00:07 +00:00
Jan Vrany
5aff891135 gdb: introduce new function create_function_type
While working on new Python API to create new function types I realized
that there's no easy way to create a new function type and control where
it is going to be allocated (whether in gdbarch's obstack or objfile's).
Functions lookup_function_type and lookup_function_type_with_arguments
always allocate at the same obstack as its return type.

This is not sufficient for the new Python API - the user may use any
type it can get hold of. For example, one may want to create a function
returning arch-owned type and taking one argument of objfile-owned type.
In that case we need to allocate the new type on that very objfile's
obstack.

This commit introduces new function - create_function_type - that takes
type_allocator as first parameter, allowing caller to control the
allocation. Existing functions (lookup_function_type and
lookup_function_type_with_arguments) are reimplemented by means of new
create_function_type.

Approved-By: Tom Tromey <tom@tromey.com>
2025-10-10 21:38:44 +01:00
Jan Beulich
1ff5a44762 bfd/PE: make local array in _bfd_XXi_swap_scnhdr_out() static
... and const. There's no reason to have the compiler copy an anonymous
.rodata object onto the stack. And there's also no reason to allow the
array to be modifiable.
2025-10-10 16:03:15 +02:00
Jan Beulich
8c41c5e09d bfd/PE: respect SEC_ALLOC when deciding whether to force IMAGE_SCN_MEM_DISCARDABLE
While in the common case sections like .reloc don't need to be accessed
by a binary (that's the job of the loader), there are rare cases where
the situation is different. Unconditionally forcing the discardable flag
is therefore unhelpful. Avoid doing so when SEC_ALLOC is set, which
would in particular be the case when .reloc isn't (solely) linker-
generated.

While adjusting the comment, drop the wrong (stale?) following sentence:
.rsrc, as per its table entry, doesn't need to be writable. And
commenting on it wanting to be readable would then need to be repeated
for all other sections as well.
2025-10-10 16:02:50 +02:00
Jan Beulich
6b7bbb6942 bfd / PE/COFF: permit SEC_READONLY and consolidate
Without SEC_READONLY, even the default .text section would end up with
the IMAGE_SCN_MEM_WRITE flag, which is clearly wrong. (Afaict the flag,
oddly enough, doesn't affect the final linked binary, so there likely
are more anomalies.)

However, as suggested by Richard Earnshaw, PE's requirements are really
target independent. Consolidate SEC_CODE, SEC_DATA, SEC_READONLY,
SEC_LINK_ONCE, and SEC_LINK_DUPLICATES into target-independent code. Yet
of course targets not using CREATE_*_COFF_TARGET_VEC() won't benefit.

Note that in coff-arm.c the EXTRA_S_FLAGS conditional was also stale
(leftover from EPOC removal), and hence can go away.
2025-10-10 16:01:16 +02:00
Jan Beulich
c0f8a4a25e gas/SH: respect --no-pad-sections
This is once again just so the target won't need excluding in a
forthcoming new testcase, which requires no padding at the end of at
least some of the sections.
2025-10-10 16:00:44 +02:00
Jan Beulich
023d89bf4b gas/SH: support BFD_RELOC_RVA in the PE/COFF case
This is just so the target won't need excluding in a forthcoming new
testcase, which uses the .rva directive.
2025-10-10 16:00:30 +02:00
Jan Beulich
2817be508d ld/PE: respect --enable-reloc-section even when .reloc isn't created by default
Even when !DLL_SUPPORT, an executable may still want to have base
relocations created. Avoid doing so by default, though, to not alter
prior behavior.

With this, an xfail can (and actually should) go away (or else we end up
with an XPASS).
2025-10-10 16:00:04 +02:00
Jan Beulich
f72471128d ld/PE: adjust pe_detail_list[]
M*Core uses pe-dll.c, but has no entry in the table. Add both big and
little endian ones. Many of the entries aren't relevant when targeting
PE+; move the #endif accordingly. The MIPS entry is actually
questionable altogether: No mips*-*-* target uses pe-dll.c or pep-dll.c.

As I lack sufficient knowledge of the target, introduction of
jmp_mcore_bytes[] will need to be handled by someone else.
2025-10-10 15:59:44 +02:00
Jan Beulich
b8c152b9a9 objdump: enable PE support for Interix
This is just so the target won't need excluding in a forthcoming new
testcase. Without doing so objdump would fail saying "option -P/--private
not supported by this file".
2025-10-10 15:59:18 +02:00
Jan Beulich
5f51d87cc0 bfd/COFF: optionally pass BFD section into swap_scnhdr_out() hook
_bfd_XXi_swap_scnhdr_out() will want to use the section's flags. Some
call sites don't have a BFD section available, and hence pass NULL. Code
using the parameter will therefore need to apply appropriate care.
2025-10-10 15:58:55 +02:00
Jan Beulich
ef3816215d bfd / PE/COFF: avoid setting SEC_ALLOC when finding IMAGE_SCN_MEM_DISCARDABLE
Before teaching _bfd_XXi_swap_scnhdr_out() to respect SEC_ALLOC when
considering whether to force IMAGE_SCN_MEM_DISCARDABLE for a section,
make sure we won't "invert" present wrong behavior when transforming an
incoming object's section attributes to an outgoing one's (objcopy or
"ld -r"): Right now, IMAGE_SCN_MEM_DISCARDABLE would appear out of the
blue for certain sections. We don't want the opposite, though, i.e. we
want avoid silently dropping IMAGE_SCN_MEM_DISCARDABLE when it's present
for an incoming object's section.
2025-10-10 15:58:30 +02:00
Jan Beulich
6e870bea5f gas/COFF: extend use of SEC_ALLOC
In line with bfd's styp_to_sec_flags(), set SEC_ALLOC for code/data
sections. Tie the setting to SEC_LOAD, not avoid inadvertently producing
a .bss-like section.
2025-10-10 15:58:03 +02:00
Jan Beulich
3f80863fbf ld/PE: adjust .reloc and .edata section flags
Both really want to be SEC_DATA, even if _bfd_XXi_swap_scnhdr_out()
makes sure that IMAGE_SCN_CNT_INITIALIZED_DATA is set in the final
section header. Otoh, .reloc - being IMAGE_SCN_MEM_DISCARDABLE at least
by default - shouldn't have SEC_ALLOC set.

In an early form of the patch I also dropped SEC_ALLOC for .reloc. While
I've undone that, I think the then necessary testsuite adjustments still
want retaining:

1) I can't explain why the removal of _both_ SEC_ALLOC and SEC_LOAD for
.reloc causes ld-scripts/provide-8 to XPASS on PE targets. Placing a
symbol outside of the image isn't well-defined in PE anyway though, so
convert the xfail-s to notarget-s.

2) The ld-pe/pe-aarch64 fragility is now dealt with in a separate patch.
2025-10-10 15:57:36 +02:00
Aditya Vidyadhar Kamath
16ca38abaa Fix AIX CI build break.
Recently AIX internal CI is broken.

The error is as follows:
--------------------------------
aix-thread.c: In function 'void sync_threadlists(pid_t)':
aix-thread.c:857:53: error: cannot convert 'thread_info' to 'thread_info*' in initialization
  857 |     for (struct thread_info *it : all_threads_safe ())
      |                                                     ^
aix-thread.c: In lambda function:
aix-thread.c:899:61: warning: declaration of 'thread' shadows a previous local [-Wshadow=compatible-local]
  899 |     thread = iterate_over_threads ([&] (struct thread_info *thread)

----------------------------------

This patch is similar to the commit https://urldefense.proofpoint.com/v2/url?u=https-3A__sourceware.org_git_-3Fp-3Dbinutils-2Dgdb.git-3Ba-3Dcommitdiff-3Bh-3D675a17a8a5cde1d8be86536df2ae6366ef0ec759&d=DwIDAg&c=BSDicqBQBDjDI9RkVyTcHQ&r=f-oUQ8ByG1nZ71OI9p76qywCPh7mxzU69hBYnkP9Nis&m=qpgW6gyN_lC_b0fBRhcWkqlvNDmUtHBTvyqGcCZxnuN6vnvJaehZ2WVuFVicJ9oD&s=UtdzAKmXnBH1ZTFOUTmFC9vTwxxralJIDjbYWsCsLYA&e=

all_threads_safe() returns an all_threads_safe_range which is like an iterator to iterate for loops.

AIX is adjusting its code in aix-thread.c for the same.

After applying this patch,
Sample test case output:

------------
gmake check RUNTESTFLAGS='gdb.threads/thread_events.exp  CC_FOR_TARGET="/opt/freeware/bin/gcc" CXX_FOR_TARGET="/opt/freeware/bin/g++" CXXFLAGS_FOR_TARGET="-O0 -w -g -gdwarf -maix64" CFLAGS_FOR_TARGET="-O0 -w -g -gdwarf -maix64"'
gmake check-single
gmake[1]: Entering directory '/upstream_gdb/binutils-gdb/gdb/testsuite'
rm -f *core* gdb.sum gdb.log
   === gdb tests ===

Schedule of variations:
    unix

Running target unix
Using /opt/freeware/share/dejagnu/baseboards/unix.exp as board description file for target.
Using /opt/freeware/share/dejagnu/config/unix.exp as generic interface file for target.
Using /upstream_gdb/binutils-gdb/gdb/testsuite/config/unix.exp as tool-and-target-specific interface file.
Running /upstream_gdb/binutils-gdb/gdb/testsuite/gdb.threads/thread_events.exp ...

                === gdb Summary ===

/upstream_gdb/binutils-gdb/gdb/gdb version  18.0.50.20251010-git -nw -nx -q -iex "set height 0" -iex "set width 0" -data-directory /upstream_gdb/binutils-gdb/gdb/data-directory -iex "set interactive-mode on"

                === gdb Summary ===

/upstream_gdb/binutils-gdb/gdb/gdb version  18.0.50.20251010-git -nw -nx -q -iex "set height 0" -iex "set width 0" -data-directory /upstream_gdb/binutils-gdb/gdb/data-directory -iex "set interactive-mode on"

gmake[1]: Leaving directory '/upstream_gdb/binutils-gdb/gdb/testsuite'

Approved By: Ulrich Weigand <ulrich.weigand@de.ibm.com>
2025-10-10 06:31:06 -05:00
Jan Beulich
6e3954c79e x86: introduce PadLock predicate
By, at least for now, (ab)using the PrefixRepe attribute, the other two
PadLock checks can be simplified.
2025-10-10 09:26:44 +02:00
Jan Beulich
5690a49ac7 x86: PadLock adjustments
For one, all PadLock insns depend on CR4.FXSR to be enabled, which means
they ought to be taking FXSR as a prereq.

Furthermore none of them permits a REPNE prefix; such forms are documented
to cause #UD. (This is mainly relevant for XSTORE, which doesn't include a
REP prefix in its base encoding. For the others this merely is a change in
what diagnostic is issued.)

Finally it is documented that an operand size prefix also causes #UD.
2025-10-10 09:26:24 +02:00
Jan Beulich
d4c517eec1 bfd/ELF: don't lose trailing globals from SHF_MERGE sections
_bfd_merged_section_offset() treats trailing symbols specially: That of
the retained section will be assigned the section size, while all ones in
replaced sections will be set to zero (which will then have output offset
added, i.e. generally the size of the retained section). However, in
neither case will the function change the section. Hence such trailing
symbols, when not originating from the retained section, will appear to
live in excluded sections, when they really belong to the sole retained
one.

Replace the section in all cases, and uniformly return section size.
2025-10-10 09:25:31 +02:00
Alice Carlotti
552ddbabb5 aarch64: Add support for FEAT_SSVE_BITPERM 2025-10-10 01:33:15 +01:00
Alice Carlotti
8a5fe4ee71 aarch64: Add support for FEAT_SSVE_FEXPA 2025-10-10 01:33:14 +01:00
Alice Carlotti
64aae286f6 aarch64: Add support for FEAT_SME_MOP4 2025-10-10 01:29:19 +01:00
Alice Carlotti
0787e01a25 aarch64: Add support for FEAT_SME_TMOP 2025-10-10 01:29:18 +01:00
Alice Carlotti
3b957f92de aarch64: Remove incorrect disassembly constraint
A check in print_insn_aarch64_word asserted that part of the encoding
space couldn't contain any valid encodings, and then returned ERR_NYI
("Not Yet Implemented", perhaps?) for these values.  However, some of
the new FEAT_MOP4 instructions will trigger the assert.  The check seems
to be outdated, and is clearly no longer valid, so it can just be
deleted.

Additionally, there are no other assignments of ERR_NYI, so delete all
remaining references to this error type.
2025-10-10 01:14:07 +01:00
Alice Carlotti
b421344f41 aarch64: Use constant fields in simple_index operands
Update aarch64_{ins|ext}_simple_index to use constant fields, and swap
the order of the index and regno fields, so that the regno occupies the
last five bits.  (Splitting/combining a variable length value and a
fixed length value is easiest if the fixed length value occupies the
least significant bits.)
2025-10-10 01:14:06 +01:00
Alice Carlotti
6c8bca7bc2 aarch64: Allow multiple fields for sve_aligned_reglist
Update aarch64_{ins|ext}_sve_aligned_reglist to use constant fields
instead of operand specific data for zero-extension/truncation.
2025-10-10 01:14:06 +01:00
Alice Carlotti
006c5e3809 aarch64: Allow multiple fields in {ins|ext}_regno
Adjust SME_PNd3/SME_PNg3 to use explicit FLD_CONST_1 bits.  This allows
the use of operand specific data to be eliminated here.
2025-10-10 01:14:06 +01:00
Alice Carlotti
ec159031ad aarch64: Extend aarch64_field to support constants
Many instructions have constraints on the range of registers they can
use.  This means that some bits in the register number are fixed, and
therefore aren't mapped to a field in the instruction encoding.
Currently we use various adhoc rules to handle these fixed bits, but
this doesn't handle all cases and we often have to write new code to
support new combinations of permitted registers.

This patch allows these constant bits to instead be specified in the
same structure used to represent instruction fields.  Uses of the new
constant fields will be introduced in subsequent patches.
2025-10-10 01:14:06 +01:00
GDB Administrator
901220f03e Automatic date update in version.in 2025-10-10 00:00:07 +00:00
Tom Tromey
f8e7ce792f Remove linespec.c:symtab_collector class
linespec.c has a symtab_collector class that is readily replaced by a
lambda.  I think the result is more clear.

I considered using the unordered_dense 'extract' method as well, to
make the code a bit more efficient -- but it wasn't clear to me if the
ordering of the vector mattered, and so I've just added a comment.

Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
2025-10-09 15:43:43 -06:00
Tom Tromey
a736ff7d88 Clean up iterate_over_symtabs
After the "search via psyms" series, there's no need for
iterate_over_symtabs to first check the expanded symtabs -- the
callback will now be called for every relevant symtab, including ones
that were already expanded before the search.

Cleaning this up enables some other cleanups.  In particular,
iterate_over_some_symtabs is not needed in its current form, so here
I've renamed it, made it static, and made it search just a single
compunit symtab.

While there I cleaned up the "invert" logic in
objfile::map_symtabs_matching_filename.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30738
Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
2025-10-09 15:32:02 -06:00
Tom Tromey
7d06ed71b8 Remove an extraneous 'return' from void method
cooked_index_functions::map_symbol_filenames returns 'void' but also
does "return ... expression".  While valid, this seems strange.  This
patch removes the unnecessary 'return'.

Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
2025-10-09 15:29:25 -06:00
Tom Tromey
fe2830c31c Convert map_symbol_filenames to method
This patch changes the free function map_symbol_filenames to be a
method of program_space.  This seems a bit cleaner, and also lets us
hoist a use of the global into the callers.

Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
2025-10-09 15:29:23 -06:00
Yodel Eldar
db6830694b doc/gdb.texinfo: Add EIO and ENOSYS errno values
This patch adds the EIO and ENOSYS errno values supported by GDB's
File-I/O to section E.14.9: Errno Values of the GDB manual [1] that were
presumably inadvertently omitted; both can be seen in the enum
fileio_error:gdbsupport/fileio.h and corresponding function
host_to_fileio_error:gdbsupport/fileio.cc as FILEIO_{EIO,ENOSYS}.

FILEIO_SUCCESS remains excluded from the manual, because its stated
purpose (commit b872057a6) is to internally represent the absence of an
error value from the remote, and it's not actually an error number.

[1] https://sourceware.org/gdb/current/onlinedocs/gdb.html/Errno-Values.html

Approved-By: Simon Marchi <simon.marchi@efficios.com>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2025-10-09 11:27:40 -04:00
Alan Modra
937aa6a37d gas/macro.c getstring
This code:
	      if (in->ptr[idx] == '!')
		{
		  idx++;
		  sb_add_char (acc, in->ptr[idx++]);
		}
and similar code in the other loop, blindly accessed the next element
of the string buffer without first checking idx against in->len,
leading to uninitialised accesses or buffer overruns.  Fix that, and
tidy the loops so that the function always returns the index one past
the last char consumed.  (It could return idx == in->len + 1).

	* macro.c (getstring): Don't access past end of input string
	buffer.  Tidy loops.  Don't return an index past in->len.
2025-10-09 16:04:06 +10:30
Simon Marchi
7b67c40b51 gdb/testsuite: make gdb.tui/gdb.sh work with dash
gdb.tui/gdb.sh (used by test gdb.tui/tuiterm-2.exp) doesn't run well
when /bin/sh is dash:

    $ bash testsuite/gdb.tui/gdb.sh
    foo^C
    $ dash testsuite/gdb.tui/gdb.sh
    footestsuite/gdb.tui/gdb.sh: 20: read: arg count

shellcheck actually points it out:

    In testsuite/gdb.tui/gdb.sh line 20:
    read
    ^--^ SC3061 (warning): In POSIX sh, read without a variable is undefined.
    ^--^ SC2162 (info): read without -r will mangle backslashes.

Fix the issue by passing the `_` dummy variable.  Using that particular
variable will not cause shellcheck to whine about it being unused.  Also
add `-r` to make it happy.

Change-Id: Ida3eddbfa3473487743fc96615baf735b4773738
2025-10-08 21:52:32 -04:00
GDB Administrator
41fa0c5ed7 Automatic date update in version.in 2025-10-09 00:00:53 +00:00
John David Anglin
dba6c21235 hppa64: Fix relocation handling for global data and a couple of thinkos
This fixes relocation handling in situations where hh->owner and
hh->sym_indx were not initialized.

2025-10-08  John David Anglin  <danglin@gcc.gnu.org>

bfd/ChangeLog:

	PR binutils/6511
	* elf64-hppa.c (global_sym_index): New from ia64.
	(elf64_hppa_check_relocs): Only set hh->eh.ref_regular if we
	have a regular definition.
	(elf64_hppa_check_relocs): Add missing NEED_DYNREL to need_entry
	assignment.
	(elf64_hppa_check_relocs): Stash symbol index and section
	earlier.
	(allocate_global_data_dlt): Initialize hh->owner and hh->sym_indx
	if not initialized.
	(allocate_global_data_opd): Likewise.  Remove redundant checks
	for NULL hh.
	(allocate_dynrel_entries): Check for discarded
	hppa_info->other_rel_sec section.  Add assert rent->sec->owner
	== hh->owner.
	(elf64_hppa_finalize_dynreloc): Check for discarded
	hppa_info->other_rel_sec section.
	(elf_hppa_final_link_relocate): Return bfd_reloc_ok if we
	have R_PARISC_NONE relocation.
2025-10-08 17:04:02 -04:00
Tom de Vries
40305c9581 [gdb/testsuite] Fix bp loc in gdb.server/fetch-exec-and-args.exp
With test-case gdb.server/fetch-exec-and-args.exp, on aarch64-linux I run into:
...
(gdb) break 28^M
Breakpoint 1 at 0xfffff7fd7b8c: file ../sysdeps/aarch64/dl-start.S, line 30.^M
(gdb) continue^M
Continuing.^M
^M
Breakpoint 1, _start () at ../sysdeps/aarch64/dl-start.S:30^M
30              mov     x0, sp^M
(gdb) PASS: $exp: packet=on: test_exec_and_arg_fetch: \
  continue to breakpoint: run to breakpoint
print argc^M
No symbol "argc" in current context.^M
(gdb) FAIL: $exp: packet=on: test_exec_and_arg_fetch: print argc
...

The problem is that the "break 28" is not specific about the file.

Fix this by setting the breakpoint on fetch-exec-and-args.c:28.

Tested on aarch64-linux.

PR testsuite/33522
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33522
2025-10-08 22:32:00 +02:00
Tom de Vries
733ccb8b3f [gdb/testsuite] Fix ERROR in expect_build_id_in_core_file
With test-case gdb.python/py-corefile.exp I run into:
...
PASS: $exp: test mapped files data: show-build-ids
ERROR: tcl error sourcing gdb.python/py-corefile.exp.
ERROR: bad option "0x1fa178": \
  must be -nobackslashes, -nocommands, or -novariables
    while executing
"subst 0x$offset + 0"
...

Fix this using "[subst 0x$offset]" instead.

Tested on x86_64-linux.
2025-10-08 22:08:49 +02:00
Sébastien Darche
aa99a69e9e gdb: add tests for per-inferior settings
I am currently upstreaming some patches from ROCgdb that were made a few
years ago. This series cleans up how the CLI and MI access parameters
for multiple inferiors.

A preceding patch (702991711a ("gdb: Have setter and getter callbacks
for settings")) allowed for per-inferior getter/setter functions of some
inferior-specific settings. Over the years a few changes were accepted
upstream (cc09d372f6 ("gdb: make set/show args work with
$_gdb_setting_str")) that implemented those capabilities.

This patch adds a few tests to verify that those settings are properly
set and accessed from the CLI, MI as well as the python interface.

Co-Authored-By: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I7a5eab210c84d6a6782a32125f68bde34d9a2339
Approved-By: Andrew Burgess <aburgess@redhat.com>
2025-10-08 16:00:33 -04:00
Sébastien Darche
b091f85b80 gdb: make deprecated_show_value_hack use its ui_file parameter
If a setting does not provide a "show" function, we fall back to the
deprecated_show_value_hack function to print the value in a generic
way. The current version ignores the `file` parameter specifying the
output file in favor of always using gdb_stdout.

To make things consistent with how the values are printed using a
regular show command, the proposed change makes the function use the
ui_file parameter it receives (even though do_show_command passes
gdb_stdout).

Co-Authored-By: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I54028ed654a1fa4d955e6e46f979472c8d98ace9
Approved-By: Andrew Burgess <aburgess@redhat.com>
2025-10-08 16:00:33 -04:00
Sébastien Darche
890bc1b7f5 gdb: do not recompute values for inferior parameters when showing them
When calling the `show` command on a few inferior-specific settings
(inferior-tty, args, cwd), GDB will recompute the values despite them
being provided by a getter.

For instance, When `show cwd` is called, `do_show_command` will query
the value of the `cwd` through `get_inferior_cwd`, which already gets
the per-inferior value. The current version seems to be a workaround
from when settings could not provide a getter function and per-inferior
settings could thus not be implemented properly, forcing the `show`
implementation to recompute the value itself.

The changes clean up the code and makes the show command trust the
values it is being forwarded, as they will always be computed by the
getter function.

Co-Authored-By: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I3b25f61f9101d98a6df7d50cee50131aec7e25c9
Approved-By: Andrew Burgess <aburgess@redhat.com>
2025-10-08 16:00:33 -04:00
Sébastien Darche
5a9a34d769 gdb: use getter/setter command styles for "set tdesc filename"
The target description filename command pair ("(set|get) tdesc
filename") uses a rather indirect way to set the variable for the
inferior, using a scratch variable to pass the value. While most other
inferior-specific parameters were updated to the more direct
getter/setter style functions, I believe this parameter was an
oversight.

This patch removes the intermediate string and directly accesses the
tdesc filename for the current inferior.

Co-Authored-By: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I2a87c65c9931ec91d15f854b32ac8279fe7077be
Approved-By: Andrew Burgess <aburgess@redhat.com>
2025-10-08 16:00:33 -04:00