Commit Graph

113471 Commits

Author SHA1 Message Date
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
Tom Tromey
bbe912ba88 Turn some value_contents functions into methods
This turns value_contents_raw, value_contents_writeable, and
value_contents_all_raw into methods on value.  The remaining functions
will be changed later in the series; they were a bit trickier and so I
didn't include them in this patch.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13 15:21:08 -07:00
Tom Tromey
ee7bb2944b Turn value_zero into static "constructor"
This turns value_zero into a static "constructor" of value.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13 15:21:08 -07:00
Tom Tromey
b27556e3c1 Turn allocate_optimized_out_value into static "constructor"
This turns allocate_optimized_out_value into a static "constructor" of
value.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13 15:21:08 -07:00
Tom Tromey
b64e260290 Turn allocate_computed_value into static "constructor"
This turns allocate_computed_value into a static "constructor" of
value.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13 15:21:07 -07:00
Tom Tromey
317c3ed9fc Turn allocate_value into a static "constructor"
This changes allocate_value to be a static "constructor" of value.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13 15:21:07 -07:00
Tom Tromey
cbe793af88 Turn allocate_value_lazy into a static "constructor"
This changes allocate_value_lazy to be a static "constructor" of
struct value.

I considered trying to change value to use ordinary new/delete, but it
seems to me that due to reference counting, we may someday want to
change these static constructors to return value_ref_ptr instead.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13 15:21:07 -07:00
Tom Tromey
f29de66504 Turn more deprecated_* functions into methods
This changes deprecated_value_internalvar_hack,
deprecated_value_internalvar_hack, and deprecated_value_regnum_hack
into methods on value.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13 15:21:07 -07:00
Tom Tromey
9feb2d07de Turn value_address and set_value_address functions into methods
This changes the value_address and set_value_address functions to be
methods of value.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13 15:21:07 -07:00
Tom Tromey
8e5b19ad99 Turn value_initialized and set_value_initialized functions into methods
This changes the value_initialized and set_value_initialized functions
to be methods of value.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13 15:21:07 -07:00
Tom Tromey
970441058c Convert value_lval_const and deprecated_lval_hack to methods
This converts the value_lval_const and deprecated_lval_hack functions
to be methods on value.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13 15:21:07 -07:00
Tom Tromey
b9f74d5432 Turn value_computed_closure and value_computed_funcs functions into methods
This changes the value_computed_funcs and value_computed_closure
functions to be methods of value.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13 15:21:07 -07:00
Tom Tromey
c8580184bb Turn value_stack and set_value_stack functions into methods
This changes the value_stack and set_value_stack functions to be
methods of value.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13 15:21:07 -07:00
Tom Tromey
3ee3b2700d Turn value_lazy and set_value_lazy functions into methods
This changes the value_lazy and set_value_lazy functions 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:21:07 -07:00
Tom Tromey
391f86284f Turn some value offset functions into method
This changes various offset-related functions 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:21:07 -07:00
Tom Tromey
463b870d01 Turn value_enclosing_type into method
This changes value_enclosing_type 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:21:07 -07:00
Tom Tromey
4b53ca8883 Turn deprecated_value_modifiable into method
This changes deprecated_value_modifiable to be a method of value.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13 15:21:07 -07:00
Tom Tromey
76675c4d0b Turn value_offset into method
This changes value_offset 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:21:07 -07:00
Tom Tromey
fac7bdaaab Turn value_parent into method
This changes value_parent 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:21:07 -07:00
Tom Tromey
5011c493fb Turn value_bitpos into method
This changes value_bitpos 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:21:07 -07:00
Tom Tromey
f49d5fa263 Turn value_bitsize into method
This changes value_bitsize 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:21:07 -07:00
Tom Tromey
f9ee742cd7 Turn value_arch into method
This changes value_arch 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:21:07 -07:00
Tom Tromey
81ae560ca4 Turn deprecated_set_value_type into a method
This changes deprecated_set_value_type 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:21:07 -07:00
Tom Tromey
d0c9791728 Turn value_type into method
This changes value_type 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:21:06 -07:00
Tom Tromey
7cf57bc5be Move struct value to value.h
This moves struct value to value.h.  For now, all members remain
public, but this is a temporary state -- by the end of the series
we'll add 'private'.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13 15:21:06 -07:00
Tom Tromey
e714001c78 Move ~value body out-of-line
struct value is going to move to value.h, but to avoid having
excessive code there, first move the destructor body out-of-line.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13 15:21:06 -07:00
Tom Tromey
382d927ffc Rename all fields of struct value
This renames all the fields of struct value, in preparation for the
coming changes.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13 15:21:06 -07:00
Michael Matz
25a0d393c7 PR30120: fix x87 fucomp misassembled
this fixes the entry for 'fucomp' to use the correct Reg value
(otherwise it's assembled as 'fucom').
2023-02-13 18:41:05 +01:00
Tom Tromey
da59d966b8 Remove unused imports from gdb's Python code
The "sys" import is unused in several Python files.  This removes this
line from all the places where it is unnecessary.
2023-02-13 10:22:48 -07:00
Andrew Burgess
d27ff777c6 gdb/tui: don't leak the known_window_types map
This commit finishes the task that was started in the previous
commit.

Now that all Python TUI window factories are correctly deleted when
the Python interpreter is shut down, we no longer need to dynamically
allocate the known_window_types map in tui-layout.c

This commit changes known_window_types to a statically allocated data
structure, removes the dynamic allocation from
initialize_known_windows, and then replaces lots of '->' with '.'
throughout this file.

There should be no user visible changes after this commit.

Reviewed-By: Tom Tromey <tom@tromey.com>
2023-02-13 14:50:51 +00:00
Andrew Burgess
9ae4519da9 gdb/python: deallocate tui window factories at Python shut down
The previous commit relied on spotting when a Python defined TUI
window factory was deleted.  I spotted that the window factories are
not deleted when GDB shuts down its Python environment, they are only
deleted when one window factory replaces another.  Consider this
example Python script:

  class TestWindowFactory:
      def __init__(self, msg):
          self.msg = msg
          print("Entering TestWindowFactory.__init__: %s" % self.msg)

      def __call__(self, tui_win):
          print("Entering TestWindowFactory.__call__: %s" % self.msg)
          return TestWindow(tui_win, self.msg)

      def __del__(self):
          print("Entering TestWindowFactory.__del__: %s" % self.msg)

  gdb.register_window_type("test_window", TestWindowFactory("A"))
  gdb.register_window_type("test_window", TestWindowFactory("B"))

And this GDB session:

  (gdb) source tui.py
  Entering TestWindowFactory.__init__: A
  Entering TestWindowFactory.__init__: B
  Entering TestWindowFactory.__del__: B
  (gdb) quit

Notice that when the 'B' window replaces the 'A' window we see the 'A'
object being deleted.  But, when Python is shut down (after the
'quit') the 'B' object is never deleted.

Instead, GDB retains a reference to the window factory object, which
forces the Python object to remain live even after the Python
interpreter itself has been shut down.

The references themselves are held in a dynamically allocated
std::unordered_map (in tui/tui-layout.c) which is never deallocated,
thus the underlying Python references are never decremented to zero,
and so GDB never tries to delete these Python objects.

This commit is the first half of the work to clean up this edge case.

All gdbpy_tui_window_maker objects (the objects that implement the
TUI window factory callback for Python defined TUI windows), are now
linked together into a global list using the intrusive list mechanism.

When GDB shuts down the Python interpreter we can now walk this global
list and release the reference that is held to the underlying Python
object.  By releasing this reference the Python object will now be
deleted.

I've added a new assert in gdbpy_tui_window_maker::operator(), this
will catch the case where we somehow end up in here after having
reset the reference to the underlying Python object.  I don't think
this should ever happen though as we only clear the references when
shutting down the Python interpreter, and the ::operator() function is
only called when trying to apply a new TUI layout - something that
shouldn't happen while GDB itself is shutting down.

This commit does not update the std::unordered_map in tui-layout.c,
that will be done in the next commit.

Reviewed-By: Tom Tromey <tom@tromey.com>
2023-02-13 14:50:46 +00:00
Andrew Burgess
d159d87072 gdb/python: allow Python TUI windows to be replaced
The documentation for gdb.register_window_type says:

  "...  It's an error to try to replace one of the built-in windows,
  but other window types can be replaced. ..."

I take this to mean that if I imported a Python script like this:

  gdb.register_window_type('my_window', FactoryFunction)

Then GDB would have a new TUI window 'my_window', which could be
created by calling FactoryFunction().  If I then, in the same GDB
session imported a script which included:

  gdb.register_window_type('my_window', UpdatedFactoryFunction)

Then GDB would replace the old 'my_window' factory with my new one,
GDB would now call UpdatedFactoryFunction().

This is pretty useful in practice, as it allows users to iterate on
their window implementation within a single GDB session.

However, right now, this is not how GDB operates.  The second call to
register_window_type is basically ignored and the old window factory
is retained.

This is because in tui_register_window (tui/tui-layout.c) we use
std::unordered_map::emplace to insert the new factory function, and
emplace doesn't replace an existing element in an unordered_map.

In this commit, before the emplace call, I now search for an already
existing element, and delete any matching element from the map, the
emplace call will then add the new factory function.

Reviewed-By: Tom Tromey <tom@tromey.com>
2023-02-13 14:50:37 +00:00
Keith Seitz
14d0e6818a Fix doc build dependencies for --with-system-readline
PR build/30108 concerns building gdb documentation with
--with-sytem-readline.  If the in-tree readline directory is
missing, though, the docs will fail to build:

make[4]: Entering directory '/home/keiths/work/readline-doc-issue/linux/gdb/doc'
make[4]: *** No rule to make target '../../../src/gdb/doc/../../readline/readline/doc/rluser.texi', needed by 'gdb.info'.  Stop.

The listed file (and hsuser.texi) are conditionally included by gdb.texinfo.
When system readline is used, gdb/configure.ac will leave
READLINE_TEXI_INCFLAGS empty, causing doc/Makefile.in to output a line to
$BUILD/doc/GDBvn.texi with "@set SYSTEM_READLINE".  This surpresses the
inclusion of the missing files. They are not needed or used in this
scenario.

However, GDB_DOC_SOURCE_INCLUDES always lists these two files as dependencies,
thus provoking the build error whenever readline/ is missing.

This patch fixes this by creating (essentially) a conditional setting of the
dependencies to be included from readline.
2023-02-13 06:14:40 -08:00
Michael Matz
b7eab2a9d4 Fix PR30079: abort on mingw
the early-out in wild_sort is not enough, it might still be
that filenames are equal _and_ the wildcard list doesn't specify
a sort order either.  Don't call compare_section then.

Tested on all targets.
2023-02-13 13:52:02 +01:00
Alan Modra
0d2f72332c _bfd_ecoff_slurp_symbol_table buffer overflow
Add missing bounds check, and tidy the existing bounds checking.

	* ecoff.c (_bfd_ecoff_slurp_symbol_table): Break overlong lines.
	Set bfd_error.  Bounds check internal_sym.iss.
2023-02-13 23:06:48 +10:30
Andrew Burgess
77be725744 opcodes/mips: disassemble unknown micromips instructions as two shorts
Before commit:

  commit 2438b771ee
  Date:   Wed Nov 2 15:53:43 2022 +0000

      opcodes/mips: use .word/.short for undefined instructions

unknown 32-bit microMIPS instructions were disassembled as a raw
32-bit number with no '.word' directive.  The above commit changed
this and added a '.word' directive before the 32-bit number.

It was pointed out on the mailing list, that for microMIPS it would be
better to display such 32-bit instructions using a '.short' directive
followed by two 16-bit values.

This commit updates the mips disassembler to do this, and adds a new
test that validates this output.
2023-02-13 12:05:32 +00:00
Andrew Burgess
97c1951915 gdb/testsuite: handle differences in guile error string output
A new guile test added in commit:

  commit 0a9ccb9dd7
  Date:   Mon Feb 6 13:04:16 2023 +0000

      gdb: only allow one of thread or task on breakpoints or watchpoints

fails for some versions of guile.  It turns out that some versions of
guile emit an error like this:

  (gdb) guile (set-breakpoint-thread! bp 1)
  ERROR: In procedure set-breakpoint-thread!:
  In procedure gdbscm_set_breakpoint_thread_x: cannot set both task and thread attributes
  Error while executing Scheme code.

while other versions of guile emit the error like this:

  (gdb) guile (set-breakpoint-thread! bp 1)
  ERROR: In procedure set-breakpoint-thread!:
  ERROR: In procedure gdbscm_set_breakpoint_thread_x: cannot set both task and thread attributes
  Error while executing Scheme code.

notice the extra 'ERROR: ' on the second line of output.  This commit
updates the test regexp to handle this optional 'ERROR: ' string.
2023-02-13 11:19:57 +00:00