Commit Graph

113457 Commits

Author SHA1 Message Date
Simon Marchi
11470e70ea gdb: store internalvars in an std::map
In a test downstream in ROCgdb, we had a test case failing when
GDB_REVERSE_INIT_FUNCTIONS was set.  The test was assuming a particular
order in the output of "show convenience".  And the order changes when
running with GDB_REVERSE_INIT_FUNCTIONS.

I think that a nice way to fix it is to make the output of "show
convenience" sorted, and therefore stable.  Ideally, I think that the
the user-visible behavior of GDB should not change when using
GDB_REVERSE_INIT_FUNCTIONS.  Plus, it makes the output of "show
convenience" look nice, not that it's really important.

Implement this by storing the internal vars in an std::map, which is a
sorted container.

Change-Id: I1fca7e7877cc984a3a3432c7639d45e68d437241
Approved-By: Tom Tromey <tom@tromey.com>
2023-02-15 11:58:24 -05:00
Simon Marchi
dbca589b8d gdb: add constructor to internalvar
Add a constructor that takes the name as a parameter.  Initialize the
next and kind fields inline.

Change-Id: Ic4db0aba85f1da9f12f3eee0ac62c0e5ef0cfe88
Approved-By: Tom Tromey <tom@tromey.com>
2023-02-15 11:58:19 -05:00
Simon Marchi
f251cb9bae gdb: use std::string for internalvar::name
Change internalvar::name to std::string, automating memory management.
It becomes necessary to allocate internalvar with new instead of XNEW.

I didn't find how to trigger the code in complete_internalvar.  It is
called from condition_completer, so it should be by using the
"condition" command, but I never managed to get in the right code path.

Change-Id: I814d61361663e7becb8f3fb5f58c0180cdc414bc
Approved-By: Tom Tromey <tom@tromey.com>
2023-02-15 11:37:17 -05:00
Tom Tromey
81b86eced2 Do not record a rejected target description
When connecting to a certain target, gdb issues a warning about the
target description:

    (gdb) target remote localhost:7947
    Remote debugging using localhost:7947
    warning: Architecture rejected target-supplied description

If you then kill the inferior and change the exec-file, this will
happen:

    (gdb) file bar
    Architecture of file not recognized.

After this, debugging doesn't work very well.

What happens here is that, despite the warning,
target_find_description records the downloaded description in the
target_desc_info.  Then the "file" command ends up calling
set_gdbarch_from_file, which uses that description.

It seems to me that, because the architecture rejected the
description, it should not be used.  That is what this patch
implements.
2023-02-15 08:59:53 -07:00
Pedro Alves
71e28f788f gdb/manual: Move @findex entries
The manual currently has many cases like these:

 @item $_gdb_setting_str (@var{setting})
 @findex $_gdb_setting_str@r{, convenience function}

As suggested by Eli, move the @findex entries before @item so that the
index records the position of @item, and the Info reader places you
there when you use index-search.

I went over all @findex calls in the manual, and most are like the
above.  Most either appear before @item, or before @subheading, like:

 @subheading The @code{-break-after} Command
 @findex -break-after

I fixed all of them.

There are findex entries in annotate.texinfo,python.texi, and
stabs.texinfo as well, though those all look right to me already.

Tested by typing "i _isvoid" (@item case) and "i -complete"
(@subheading case) in an Info reader, and checking where those took
me.

Change-Id: Idb6903b0bb39ff03f93524628dcef86b5585c97e
Suggested-By: Eli Zaretskii <eliz@gnu.org>
2023-02-15 15:28:33 +00:00
Alan Modra
f9c36cc995 objdump read_section_stabs
This function is used to read sections other than stabs, and there is
now another version of it that extracts different info from the bfd
section.  Rename it and return the bfd section instead of assorted
fields of the bfd section.

	* objcopy.c (read_section): Renamed from read_section_stabs.
	Delete size_ptr and entsize_ptr params, add contents param.
	Return asection pointer.  Don't unnecessarily free contents on
	failure from bfd_malloc_and_get_section.
	(find_stabs_section): Use read_section.
	(dump_ctf, dump_section_sframe): Likewise.
	(read_section_sframe): Delete.
2023-02-15 22:03:30 +10:30
Alan Modra
11066c2aab objdump -G memory leak
* objdump.c (find_stabs_section): Free stabs.
2023-02-15 22:03:30 +10:30
Nick Clifton
2b56cd9191 Fix the linker's merge4 test for the HPPA architecture.
PR 30078 * testsuite/ld-elf/merge4b.s: Use .asciz instead of .string in order to avoid the special behaviour of the .string directive on HPPA architectures.
2023-02-15 09:26:10 +00:00
Felix Willgerodt
ecbc5c4f90 gdb, fortran: Fix quad floating-point type for ifort compiler.
I fixed this a while ago for ifx, one of the two Intel compilers, in
8d624a9d80.

Apparently I missed that the older ifort Intel compiler actually emits
slightly different debug info again:

0x0000007a:   DW_TAG_base_type
                DW_AT_byte_size	(0x20)
                DW_AT_encoding	(DW_ATE_complex_float)
                DW_AT_name	("COMPLEX(16)")

0x00000081:   DW_TAG_base_type
                DW_AT_byte_size	(0x10)
                DW_AT_encoding	(DW_ATE_float)
                DW_AT_name	("REAL(16)")

This fixes two failures in gdb.fortran/complex.exp with ifort.

Approved-By: Tom Tromey <tom@tromey.com>
2023-02-15 09:51:28 +01:00
Jan Beulich
c22a747283 gas: buffer_and_nest() needs to pass nul-terminated string to temp_ilp()
In 7545aa2dd2 ("gas: improve interaction between read_a_source_file()
and s_linefile()") I didn't pay attention to the dual purpose of the
nul character previously used. This was to a fair degree because of the
open-coding of certain operations. Insert the earlier found line
terminator instead of a hard-coded newline, and do so early in this
special case (bypassing the later general insertion point). Plus
properly use sb_terminate() to mark the end of the string. (Note that
saved_eol_char was misnamed: Without calling sb_terminate() there's
simply random data at that position in the buffer.)
2023-02-15 08:46:02 +01:00
Alan Modra
c917143097 More ecoff sanity checks
Change FIX so that unused pointers that escape the UPDATE_RAW_END
sanity checks won't result in overflows.  Also sanity check the local
sym fdr isymBase and csym values.

	* ecoff.c (_bfd_ecoff_slurp_symbolic_info): Define FIX to set
	pointers into swapped internal data to NULL if count is zero.
	Sanity check local sym fdr_ptr->isymBase and fdr_ptr->csym.
2023-02-15 16:36:00 +10:30
Alan Modra
72d225ef9c binutils stabs type list
Fuzzers have found that specifying a large stab type number results in
lots of memory being requested, as the list is extended with a 16
element array at a time until we reach the given stab type.  It also
takes a long time.  Of course normal sane stab types use small
positive integers, but it's not hard to modify the code to handle type
numbers starting anyhere.

	* stabs.c (struct stab_types): Add base_index.
	(stab_find_slot): Simplify filenum check.  Delete type number
	check.  Don't allocate entire array from 0 to type number,
	allocate a sparse array.
2023-02-15 13:05:28 +10:30
GDB Administrator
3cd0b4f2c0 Automatic date update in version.in 2023-02-15 00:00:24 +00:00
Tom Tromey
34116a8a2d Remove a use of pagination_enabled
I noticed that the TUI temporarily sets pagination_enabled and
gdb_stdout in one spot.  However, I don't believe these settings are
necessary here, as a ui_file is passed to
gdbarch_print_registers_info.  This patch removes these settings.
2023-02-14 13:54:44 -07:00
Simon Marchi
9981e299e1 gdb/dwarf2: rename some things, index -> gdb_index
This renaming helps make it clearer that these entites (classes,
functions) are specific to .gdb_index only, they are not shared with the
.debug_names handling.

Change-Id: I1a3cf3dbf450b62d1a0879d9aedd26397abdfd13
Approved-By: Tom Tromey <tom@tromey.com>
2023-02-14 14:30:35 -05:00
Simon Marchi
8eaecfb37c gdb: cast return value of std::unique_ptr::release to void
My editor shows warnings like:

     value.c:2784: warning: The value returned by this function should be used
     value.c:2784: note: cast the expression to void to silence this warning [bugprone-unused-return-value]

These warnings come from clangd, so ultimately from one of the clang
static analyzers (probably clang-tidy).

Silence these warnings by casting to void.  Add a comment to explain
why this unusual thing is done.

Change-Id: I58323959c0baf9f1b20a8d596e4c58dc77c6809a
Approved-By: Tom Tromey <tom@tromey.com>
2023-02-14 14:25:48 -05:00
Simon Marchi
92a2cc556c gdb: remove unnecessary tui directory check in configure
I suppose this was possible in the CVS days for the tui directory to be
missing, but it's not really possible nowaday.  Well, a user could
delete the directory from their source tree but... it doesn't make
sense.  Remove the check for that directory in configure.

Change-Id: Iea1412f5e5482ed003015030132ec22150c7d0b3
Approved-By: Tom Tromey <tom@tromey.com>
2023-02-14 13:31:29 -05:00
Tom Tromey
81aa19c303 Do not cast away const in agent_run_command
While investigating something else, I noticed some weird code in
agent_run_command (use of memcpy rather than strcpy).  Then I noticed
that 'cmd' is used as both an in and out parameter, despite being
const.

Casting away const like this is bad.  This patch removes the const and
fixes the memcpy.  I also added a static assert to assure myself that
the code in gdbserver is correct -- gdbserver is passing its own
buffer directly to agent_run_command.

Reviewed-By: Andrew Burgess <aburgess@redhat.com>
2023-02-14 09:01:18 -07:00
Tom de Vries
5bed9dc992 [gdb/testsuite] Add xfail in gdb.python/py-record-btrace.exp
There's a HW bug affecting Processor Trace on some Intel processors
(Ice Lake to Raptor Lake microarchitectures).

The bug was exposed by linux kernel commit 670638477aed
("perf/x86/intel/pt: Opportunistically use single range output mode"),
added in version v5.5.0, and was worked around by commit ce0d998be927
("perf/x86/intel/pt: Fix sampling using single range output") in version
6.1.0.

The bug manifests (on a Performance-core of an i7-1250U, an Alder Lake cpu) in
a single test-case:
...
(gdb) python insn = r.instruction_history^M
warning: Decode error (-20) at instruction 33 (offset = 0x3d6a, \
  pc = 0x400501): compressed return without call.^M
(gdb) FAIL: gdb.python/py-record-btrace.exp: prepare record: \
  python insn = r.instruction_history
...

Add a corresponding XFAIL.

Note that the i7-1250U has both Performance-cores and Efficient-cores, and on
an Efficient-Core the test-case runs without any problems, so if the testsuite
run is not pinned to a specific cpu, the test may either PASS or XFAIL.

Tested on x86_64-linux:
- openSUSE Leap 15.4 with linux kernel version 5.14.21
- openSUSE Tumbleweed with linux kernel version 6.1.8

PR testsuite/30075
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30075
2023-02-14 13:15:49 +01:00
Nick Clifton
9b38b85ec3 Mention that the -plugin command line option is used to load plugins. 2023-02-14 12:01:06 +00:00
Tom de Vries
37d75d4552 [gdb/testsuite] Factor out proc linux_kernel_version
Factor out new proc linux_kernel_version from test-case
gdb.arch/i386-pkru.exp.

Tested on x86_64-linux.
2023-02-14 11:53:54 +01:00
Ulf Samuelsson
0d79a2a8e2 ASCIZ Command for output section
Adds a new directive to the linker script syntax: ASCIZ.
This inserts a zero-terminated string into the output at the place where it is used.
2023-02-14 10:13:28 +00:00
Jan Beulich
12ef683055 gas: correct symbol name comparison in .startof./.sizeof. handling
In 162c6aef1f ("gas: fold symbol table entries generated for
.startof.() / .sizeof.()") I screwed up quite badly, inverting the case
sensitive and case insensitive comparison functions.
2023-02-14 08:35:02 +01:00
Jan Beulich
676dcbb0a0 x86: {LD,ST}TILECFG use an extension opcode
It being zero and happening to work right now doesn't mean the insns
shouldn't be spelled out properly.
2023-02-14 08:34:42 +01:00
Jan Beulich
7545aa2dd2 gas: improve interaction between read_a_source_file() and s_linefile()
read_a_source_file() would bump line numbers only when seeing a newline,
whereas is_end_of_line[] indicates further end-of-line characters, in
particular the nul character. s_linefile() attempts to compensate for
the bump, but was too aggressive with this so far: It should only adjust
when a newline ends the line. To facilitate such a check, the check for
nothing else on the line needs to move ahead, which luckily is easily
possible: The relevant two conditions match, and the function can
simply return from the body of that earlier instance of the conditional.

The more strict treatment in s_linefile() then requires an adjustment
to buffer_and_nest()'s invocation of the function: The line terminator
now needs to be a newline, not nul.
2023-02-14 08:34:03 +01:00
Tom Tromey
f54cd6441d Fix build bug in ppc-linux-nat.c
The buildbot pointed out that my value refactoring series introduced a
bug in ppc-linux-nat.c:

../../binutils-gdb/gdb/ppc-linux-nat.c: In member function ‘int ppc_linux_nat_target::num_memory_accesses(const std::vector<gdb::ref_ptr<value, value_ref_policy> >&)’:
../../binutils-gdb/gdb/ppc-linux-nat.c:2458:44: error: expected unqualified-id before ‘->’ token
 2458 |       if (VALUE_LVAL (v) == not_lval || v->->deprecated_modifiable () == 0)

I don't know how that happened, but I am checking in this patch which
I think should fix it.  It just removes the second "->".

I can't readily test this, so perhaps there's another bug lurking
after this one.
2023-02-14 00:31:04 -07:00
GDB Administrator
978042640c Automatic date update in version.in 2023-02-14 00:00:22 +00:00
Tom Tromey
f28085dfb4 Rely on value_ref_ptr::operator->
Simon pointed out some spots were doing val.get()->mumble, where val
is a value_ref_ptr.  These were introduced by the function-to-method
script, replacing older code that passed the result of .get() to a
function.

Now that value.h is using methods, we can instead rely on operator->.
This patch replaces all the newly-introduced instances of this.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13 15:24:27 -07:00
Tom Tromey
736355f2e1 Remove deprecated_lval_hack
This removes deprecated_lval_hack and the VALUE_LVAL macro, replacing
all uses with a call to value::lval.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13 15:22:20 -07:00
Tom Tromey
6f9c9d71c2 Introduce set_lval method on value
This introduces the set_lval method on value, one step toward removing
deprecated_lval_hack.  Ultimately I think the goal should be for some
of these set_* methods to be replaced with constructors; but I haven't
done this, as the series is already too long.  Other 'deprecated'
methods can probably be handled the same way.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13 15:22:20 -07:00
Tom Tromey
43b5fba223 Make ~value private
At the end of this series, I belatedly realized that values should
only be destroyed by value_decref.  This patch marks the the
destructor private to enforce this.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13 15:22:20 -07:00
Tom Tromey
8f4135314a Make struct value data members private
This hoists the 'private' in struct value to also encompass the data
members.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13 15:22:20 -07:00
Tom Tromey
0d0f488e1d Turn record_latest_value into a method
record_latest_value now access some internals of struct value, so turn
it into a method.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13 15:22:17 -07:00
Tom Tromey
e6cf1e1b42 Add value::set_modifiable
This introduces a value::set_modifiable and changes a couple of spots
to use it.

I'm not completely sure the comments by deprecated_modifiable are
correct any more.  Perhaps they should be removed and the method
renamed.  Like so many before me, though, I've deferred investigation
of the issue.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13 15:22:17 -07:00
Tom Tromey
6c49729e59 Turn various value copying-related functions into methods
This patch turns a grab bag of value functions to methods of value.
These are done together because their implementations are
interrelated.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13 15:22:17 -07:00
Tom Tromey
e3fb3c4772 Turn preserve_one_value into method
This changes preserve_one_value to be a method of value.  Much of this
patch was written by script.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13 15:22:17 -07:00
Tom Tromey
6bd5c75435 Turn some xmethod functions into methods
This turns value_from_xmethod, result_type_of_xmethod, and
call_xmethod to be methods of value.  value_from_xmethod is a static
"constructor" now.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13 15:22:17 -07:00
Tom Tromey
fcf86fe597 Change some code to use value methods
A few functions in value.c were accessing the internal fields of
struct value.  However, in these cases it seemed simpler to change
them to use the public API rather than convert them to be methods.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13 15:22:17 -07:00
Tom Tromey
8181b7b657 Turn set_value_component_location into method
This turns set_value_component_location into a method of value.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13 15:22:17 -07:00
Tom Tromey
aa9f4538cc Turn value_non_lval and value_force_lval into methods
This changes value_non_lval and value_force_lval to be methods of
value.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13 15:22:17 -07:00
Tom Tromey
d00664dbba Turn many optimized-out value functions into methods
This turns many functions that are related to optimized-out or
availability-checking to be methods of value.  The static function
value_entirely_covered_by_range_vector is also converted to be a
private method.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13 15:22:17 -07:00
Tom Tromey
cda0334434 Turn value_copy into a method
This turns value_copy into a method of value.  Much of this was
written by script.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13 15:22:16 -07:00
Tom Tromey
e18312bb59 Fully qualify calls to copy in value.c
A coming patch will add value::copy, so this namespace-qualifies
existing calls to 'copy' in value.c, to ensure it will still compile
after that change is done.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13 15:22:16 -07:00
Tom Tromey
efaf1ae025 Turn remaining value_contents functions into methods
This turns the remaining value_contents functions -- value_contents,
value_contents_all, value_contents_for_printing, and
value_contents_for_printing_const -- into methods of value.  It also
converts the static functions require_not_optimized_out and
require_available to be private methods.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13 15:22:16 -07:00
Tom Tromey
cdf3de175d Turn value_incref and value_decref into methods
This changes value_incref and value_decref to be methods of value.
Much of this patch was written by script.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13 15:22:16 -07:00
Tom Tromey
d3824ae14a Move value_ref_policy methods out-of-line
This moves the value_ref_policy methods to be defined out-of-line.
This is a necessary step to change value_incref and value_decref to be
methods of value.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13 15:22:16 -07:00
Tom Tromey
e989e63761 Turn value_bits_synthetic_pointer into a method
This changes value_bits_synthetic_pointer to be a method of value.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13 15:22:16 -07:00
Tom Tromey
02744ba9a2 Turn value_contents_eq into a method
This changes value_contents_eq to be a method of value.  It also
converts the static function value_contents_bits_eq into a private
method.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13 15:22:16 -07:00
Tom Tromey
82ca8f7201 Turn allocate_value_contents into a method
This turns the static function allocate_value_contents into a method
on value.  It is temporarily public, until some users are converted.
set_limited_array_length is converted as well.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13 15:22:12 -07:00
Tom Tromey
78259c365f Turn value_fetch_lazy into a method
This changes value_fetch_lazy to be a method of value.  A few helper
functions are converted as well, to avoid problems in later patches
when the data members are all made private.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13 15:22:04 -07:00