Commit Graph

244 Commits

Author SHA1 Message Date
Tom Tromey
c819a3380f Replace field_is_static with a method
This changes field_is_static to be a method on struct field, and
updates all the callers.  Most of this patch was written by script.

Regression tested on x86-64 Fedora 36.
2023-05-01 09:20:37 -06:00
Tom Tromey
5309ce2f04 Convert long_const_operation to use gdb_mpz
This changes long_const_operation to use gdb_mpz for its storage.
2023-04-17 10:43:06 -06:00
Tom Tromey
935d48567d Handle range types in ax-gdb.c
A range type can usually be treated the same as its underlying integer
type, at least for the purposes of agent expressions.  This patch
arranges for range types to be handled this way in ax-gdb.c, letting a
somewhat larger subset of Ada expressions be compiled.
2023-02-27 08:09:02 -07:00
Tom Tromey
3c9d050626 Convert block_linkage_function to method
This converts block_linkage_function to be a method.  This was mostly
written by script.
2023-02-19 12:51:05 -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
Joel Brobecker
213516ef31 Update copyright year range in header of all files managed by GDB
This commit is the result of running the gdb/copyright.py script,
which automated the update of the copyright year range for all
source files managed by the GDB project to be updated to include
year 2023.
2023-01-01 17:01:16 +04:00
Pedro Alves
f34652de0b internal_error: remove need to pass __FILE__/__LINE__
Currently, every internal_error call must be passed __FILE__/__LINE__
explicitly, like:

  internal_error (__FILE__, __LINE__, "foo %d", var);

The need to pass in explicit __FILE__/__LINE__ is there probably
because the function predates widespread and portable variadic macros
availability.  We can use variadic macros nowadays, and in fact, we
already use them in several places, including the related
gdb_assert_not_reached.

So this patch renames the internal_error function to something else,
and then reimplements internal_error as a variadic macro that expands
__FILE__/__LINE__ itself.

The result is that we now should call internal_error like so:

  internal_error ("foo %d", var);

Likewise for internal_warning.

The patch adjusts all calls sites.  99% of the adjustments were done
with a perl/sed script.

The non-mechanical changes are in gdbsupport/errors.h,
gdbsupport/gdb_assert.h, and gdb/gdbarch.py.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
Change-Id: Ia6f372c11550ca876829e8fd85048f4502bdcf06
2022-10-19 15:32:36 +01:00
Tom Tromey
bd2b40ac12 Change GDB to use frame_info_ptr
This changes GDB to use frame_info_ptr instead of frame_info *
The substitution was done with multiple sequential `sed` commands:

sed 's/^struct frame_info;/class frame_info_ptr;/'
sed 's/struct frame_info \*/frame_info_ptr /g' - which left some
    issues in a few files, that were manually fixed.
sed 's/\<frame_info \*/frame_info_ptr /g'
sed 's/frame_info_ptr $/frame_info_ptr/g' - used to remove whitespace
    problems.

The changed files were then manually checked and some 'sed' changes
undone, some constructors and some gets were added, according to what
made sense, and what Tromey originally did

Co-Authored-By: Bruno Larsen <blarsen@redhat.com>
Approved-by: Tom Tomey <tom@tromey.com>
2022-10-10 11:57:10 +02:00
Simon Marchi
df86565b31 gdb: remove TYPE_LENGTH
Remove the macro, replace all uses with calls to type::length.

Change-Id: Ib9bdc954576860b21190886534c99103d6a47afb
2022-09-21 11:05:21 -04:00
Simon Marchi
27710edb4e gdb: remove TYPE_TARGET_TYPE
Remove the macro, replace all uses by calls to type::target_type.

Change-Id: Ie51d3e1e22f94130176d6abd723255282bb6d1ed
2022-09-21 10:59:49 -04:00
Tom Tromey
5f48d886a9 Use checked_static_cast in more places
I went through all the uses of dynamic_cast<> in gdb, looking for ones
that could be replaced with checked_static_cast.  This patch is the
result.  Regression tested on x86-64 Fedora 34.
2022-09-12 14:25:06 -06:00
Pedro Alves
264f98902f event_location -> location_spec
Currently, GDB internally uses the term "location" for both the
location specification the user input (linespec, explicit location, or
an address location), and for actual resolved locations, like the
breakpoint locations, or the result of decoding a location spec to
SaLs.  This is expecially confusing in the breakpoints module, as
struct breakpoint has these two fields:

  breakpoint::location;
  breakpoint::loc;

"location" is the location spec, and "loc" is the resolved locations.

And then, we have a method called "locations()", which returns the
resolved locations as range...

The location spec type is presently called event_location:

  /* Location we used to set the breakpoint.  */
  event_location_up location;

and it is described like this:

  /* The base class for all an event locations used to set a stop event
     in the inferior.  */

  struct event_location
  {

and even that is incorrect...  Location specs are used for finding
actual locations in the program in scenarios that have nothing to do
with stop events.  E.g., "list" works with location specs.

To clean all this confusion up, this patch renames "event_location" to
"location_spec" throughout, and then all the variables that hold a
location spec, they are renamed to include "spec" in their name, like
e.g., "location" -> "locspec".  Similarly, functions that work with
location specs, and currently have just "location" in their name are
renamed to include "spec" in their name too.

Change-Id: I5814124798aa2b2003e79496e78f95c74e5eddca
2022-06-17 09:41:24 +01:00
Simon Marchi
6395b62847 gdb: remove BLOCK_ENTRY_PC macro
Replace with equivalent method.

Change-Id: I0e033095e7358799930775e61028b48246971a7d
2022-04-27 22:05:03 -04:00
Simon Marchi
4aeddc50d7 gdb: remove symbol value macros
Remove all macros related to getting and setting some symbol value:

    #define SYMBOL_VALUE(symbol)           (symbol)->value.ivalue
    #define SYMBOL_VALUE_ADDRESS(symbol)                         \
    #define SET_SYMBOL_VALUE_ADDRESS(symbol, new_value)    \
    #define SYMBOL_VALUE_BYTES(symbol)     (symbol)->value.bytes
    #define SYMBOL_VALUE_COMMON_BLOCK(symbol) (symbol)->value.common_block
    #define SYMBOL_BLOCK_VALUE(symbol)     (symbol)->value.block
    #define SYMBOL_VALUE_CHAIN(symbol)     (symbol)->value.chain
    #define MSYMBOL_VALUE(symbol)          (symbol)->value.ivalue
    #define MSYMBOL_VALUE_RAW_ADDRESS(symbol) ((symbol)->value.address + 0)
    #define MSYMBOL_VALUE_ADDRESS(objfile, symbol)                         \
    #define BMSYMBOL_VALUE_ADDRESS(symbol) \
    #define SET_MSYMBOL_VALUE_ADDRESS(symbol, new_value)   \
    #define MSYMBOL_VALUE_BYTES(symbol)    (symbol)->value.bytes
    #define MSYMBOL_BLOCK_VALUE(symbol)    (symbol)->value.block

Replace them with equivalent methods on the appropriate objects.

Change-Id: Iafdab3b8eefc6dc2fd895aa955bf64fafc59ed50
2022-04-11 10:45:36 -04:00
Andrew Burgess
6f0dabd46d gdb/x86: handle stap probe arguments in xmm registers
On x86 machines with xmm register, and with recent versions of
systemtap (and gcc?), it can occur that stap probe arguments will be
placed into xmm registers.

I notice this happening on a current Fedora Rawhide install with the
following package versions installed:

  $ rpm -q glibc systemtap gcc
  glibc-2.35.9000-10.fc37.x86_64
  systemtap-4.7~pre16468670g9f253544-1.fc37.x86_64
  gcc-12.0.1-0.12.fc37.x86_64

If I check the probe data in libc, I see this:

  $ readelf -n /lib64/libc.so.6
  ...
  stapsdt              0x0000004d       NT_STAPSDT (SystemTap probe descriptors)
    Provider: libc
    Name: pthread_start
    Location: 0x0000000000090ac3, Base: 0x00000000001c65c4, Semaphore: 0x0000000000000000
    Arguments: 8@%xmm1 8@1600(%rbx) 8@1608(%rbx)
  stapsdt              0x00000050       NT_STAPSDT (SystemTap probe descriptors)
    Provider: libc
    Name: pthread_create
    Location: 0x00000000000912f1, Base: 0x00000000001c65c4, Semaphore: 0x0000000000000000
    Arguments: 8@%xmm1 8@%r13 8@8(%rsp) 8@16(%rsp)
  ...

Notice that for both of these probes, the first argument is a uint64_t
stored in the xmm1 register.

Unfortunately, if I try to use this probe within GDB, then I can't
view the first argument.  Here's an example session:

  $ gdb $(which gdb)
  (gdb) start
  ...
  (gdb) info probes stap  libc pthread_create
  ...
  (gdb) break *0x00007ffff729e2f1       # Use address of probe.
  (gdb) continue
  ...
  (gdb) p $_probe_arg0
  Invalid cast.

What's going wrong?  If I re-run my session, but this time use 'set
debug stap-expression 1', this is what I see:

  (gdb) set debug stap-expression 1
  (gdb) p $_probe_arg0
  Operation: UNOP_CAST
   Operation: OP_REGISTER
    String: xmm1
   Type: uint64_t
  Operation: UNOP_CAST
   Operation: OP_REGISTER
    String: r13
   Type: uint64_t
  Operation: UNOP_CAST
   Operation: UNOP_IND
    Operation: UNOP_CAST
     Operation: BINOP_ADD
      Operation: OP_LONG
       Type: long
       Constant: 0x0000000000000008
      Operation: OP_REGISTER
       String: rsp
     Type: uint64_t *
   Type: uint64_t
  Operation: UNOP_CAST
   Operation: UNOP_IND
    Operation: UNOP_CAST
     Operation: BINOP_ADD
      Operation: OP_LONG
       Type: long
       Constant: 0x0000000000000010
      Operation: OP_REGISTER
       String: rsp
     Type: uint64_t *
   Type: uint64_t
  Invalid cast.
  (gdb)

The important bit is this:

  Operation: UNOP_CAST
   Operation: OP_REGISTER
    String: xmm1
   Type: uint64_t

Which is where we cast the xmm1 register to uint64_t.  And the final
piece of the puzzle is:

  (gdb) ptype $xmm1
  type = union vec128 {
      v8bf16 v8_bfloat16;
      v4f v4_float;
      v2d v2_double;
      v16i8 v16_int8;
      v8i16 v8_int16;
      v4i32 v4_int32;
      v2i64 v2_int64;
      uint128_t uint128;
  }

So, we are attempting to cast a union type to a scalar type, which is
not supporting in C/C++, and as a consequence GDB's expression
evaluator throws an error when we attempt to do this.

The first approach I considered for solving this problem was to try
and make use of gdbarch_stap_adjust_register.  We already have a
gdbarch method (gdbarch_stap_adjust_register) that allows us to tweak
the name of the register that we access.  Currently only x86
architectures use this to transform things like ax to eax in some
cases.

I wondered, what if we change gdbarch_stap_adjust_register to do more
than just change the register names?  What if this method instead
became gdbarch_stap_read_register.  This new method would return a
operation_up, and would take the register name, and the type we are
trying to read from the register, and return the operation that
actually reads the register.

The default implementation of this method would just use
user_reg_map_name_to_regnum, and then create a register_operation,
like we already do in stap_parse_register_operand.  But, for x86
architectures this method would fist possibly adjust the register
name, then do the default action to read the register.  Finally, for
x86 this method would spot when we were accessing an xmm register,
and, based on the type being pulled from the register, would extract
the correct field from the union.

The benefit of this approach is that it would work with the expression
types that GDB currently supports.  The draw back would be that this
approach would not be very generic.  We'd need code to handle each
sub-field size with an xmm register.  If other architectures started
using vector registers for probe arguments, those architectures would
have to create their own gdbarch_stap_read_register method.  And
finally, the type of the xmm registers comes from the type defined in
the target description, there's a risk that GDB might end up
hard-coding the names of type sub-fields, then if a target uses a
different target description, with different field names for xmm
registers, the stap probes would stop working.

And so, based on all the above draw backs, I rejected this first
approach.

My second plan involves adding a new expression type to GDB called
unop_extract_operation.  This new expression takes a value and a type,
during evaluation the value contents are fetched, and then a new value
is extracted from the value contents (based on type).  This is similar
to the following C expression:

  result_value = *((output_type *) &input_value);

Obviously we can't actually build this expression in this case, as the
input_value is in a register, but hopefully the above makes it clearer
what I'm trying to do.

The benefit of the new expression approach is that this code can be
shared across all architectures, and it doesn't care about sub-field
names within the union type.

The draw-backs that I see are potential future problems if arguments
are not stored within the least significant bytes of the register.
However if/when that becomes an issue we can adapt the
gdbarch_stap_read_register approach to allow architectures to control
how a value is extracted.

For testing, I've extended the existing gdb.base/stap-probe.exp test
to include a function that tries to force an argument into an xmm
register.  Obviously, that will only work on a x86 target, so I've
guarded the new function with an appropriate GCC define.  In the exp
script we use readelf to check if the probe exists, and is using the
xmm register.

If the probe doesn't exist then the associated tests are skipped.

If the probe exists, put isn't using the xmm register (which will
depend on systemtap/gcc versions), then again, the tests are skipped.

Otherwise, we can run the test.  I think the cost of running readelf
is pretty low, so I don't feel too bad making all the non-xmm targets
running this step.

I found that on a Fedora 35 install, with these packages installed, I
was able to run this test and have the probe argument be placed in an
xmm register:

  $ rpm -q systemtap gcc glibc
  systemtap-4.6-4.fc35.x86_64
  gcc-11.2.1-9.fc35.x86_64
  glibc-2.34-7.fc35.x86_64

Finally, as this patch adds a new operation type, then I need to
consider how to generate an agent expression for the new operation
type.

I have kicked the can down the road a bit on this.  In the function
stap_parse_register_operand, I only create a unop_extract_operation in
the case where the register type is non-scalar, this means that in
most cases I don't need to worry about generating an agent expression
at all.

In the xmm register case, when an unop_extract_operation will be
created, I have sketched out how the agent expression could be
handled, however, this code is currently not reached.  When we try to
generate the agent expression to place the xmm register on the stack,
GDB hits this error:

  (gdb) trace -probe-stap test:xmmreg
  Tracepoint 1 at 0x401166
  (gdb) actions
  Enter actions for tracepoint 1, one per line.
  End with a line saying just "end".
  >collect $_probe_arg0
  Value not scalar: cannot be an rvalue.

This is because GDB doesn't currently support placing non-scalar types
on the agent expression evaluation stack.  Solving this is clearly
related to the original problem, but feels a bit like a second
problem.  I'd like to get feedback on whether my approach to solving
the original problem is acceptable or not before I start looking at
how to handle xmm registers within agent expressions.
2022-03-21 14:39:14 +00:00
Simon Marchi
5f9c5a63ce gdb: remove SYMBOL_TYPE macro
Add a getter and a setter for a symbol's type.  Remove the corresponding
macro and adjust all callers.

Change-Id: Ie1a137744c5bfe1df4d4f9ae5541c5299577c8de
2022-02-06 16:03:47 -05:00
Simon Marchi
66d7f48f80 gdb: remove SYMBOL_CLASS macro, add getter
Change-Id: I83211d5a47efc0564386e5b5ea4a29c00b1fd46a
2022-02-06 16:03:46 -05:00
Joel Brobecker
4a94e36819 Automatic Copyright Year update after running gdb/copyright.py
This commit brings all the changes made by running gdb/copyright.py
as per GDB's Start of New Year Procedure.

For the avoidance of doubt, all changes in this commits were
performed by the script.
2022-01-01 19:13:23 +04:00
Simon Marchi
c32ce0dc6c gdb: rename "maint agent" functions
Functions agent_eval_command and agent_command are used to implement
maintenance commands, rename them accordingly (with the maint_ prefix),
as well as the agent_command_1 helper function.

Change-Id: Iacf96d4a0a26298e8dd4648a0f38da649ea5ef61
2021-12-07 15:56:25 -05:00
Simon Marchi
557b4d7650 gdbsupport: make gdb_assert_not_reached accept a format string
Change gdb_assert_not_reached to accept a format string plus
corresponding arguments.  This allows giving more precise messages.

Because the format string passed by the caller is prepended with a "%s:"
to add the function name, the callers can no longer pass a translated
string (`_(...)`).  Make the gdb_assert_not_reached include the _(),
just like the gdb_assert_fail macro just above.

Change-Id: Id0cfda5a57979df6cdaacaba0d55dd91ae9efee7
2021-11-18 11:29:19 -05:00
Simon Marchi
e06c3e112e gdb: remove TYPE_FIELD_STATIC_PHYSADDR
Remove TYPE_FIELD_STATIC_PHYSADDR replace with type::field +
field::loc_physaddr.

Change-Id: Ica9bc4a48f34750ec82ec86c298d3ecece81bcbd
2021-10-29 16:44:45 -04:00
Simon Marchi
fcbbbd90f0 gdb: remove TYPE_FIELD_STATIC_PHYSNAME
Remove TYPE_FIELD_STATIC_PHYSNAME, replace with type::field +
field::loc_physname.

Change-Id: Ie35d446b67dd1d02f39998b406001bdb7e6d5abb
2021-10-29 16:44:45 -04:00
Simon Marchi
b610c04548 gdb: remove TYPE_FIELD_BITPOS
Remove TYPE_FIELD_BITPOS, replace its uses with type::field +
field::loc_bitpos.

Change-Id: Iccd8d5a77e5352843a837babaa6bd284162e0320
2021-10-29 16:44:44 -04:00
Simon Marchi
2ad53ea10c gdb: remove TYPE_FIELD_LOC_KIND
Remove TYPE_FIELD_LOC_KIND, replace its uses with type::field +
field::loc_kind.

Change-Id: Ib124a26365df82ac1d23df7962d954192913bd90
2021-10-29 16:44:21 -04:00
Simon Marchi
33d16dd987 gdb: remove TYPE_FIELD_NAME and FIELD_NAME macros
Remove the `TYPE_FIELD_NAME` and `FIELD_NAME` macros, changing all the
call sites to use field::name directly.

Change-Id: I6900ae4e1ffab1396e24fb3298e94bf123826ca6
2021-09-30 22:05:57 -04:00
Tom Tromey
809f3be12c Change pointer_type to a method of struct type
I noticed that pointer_type is declared in language.h and defined in
language.c.  However, it really has to do with types, so it should
have been in gdbtypes.h all along.

This patch changes it to be a method on struct type.  And, I went
through uses of TYPE_IS_REFERENCE and updated many spots to use the
new method as well.  (I didn't update ones that were in arch-specific
code, as I couldn't readily test that.)
2021-09-23 15:11:00 -06:00
Tom Tromey
9e5e03df52 Use block_symbol in var_value_operation
I noticed that var_value_operation takes a block and a symbol, and
most callers destructure a block_symbol to pass in.  It seems better
for this class to simply hold a block_symbol instead.

Tested on x86-64 Fedora 32.

gdb/ChangeLog
2021-04-15  Tom Tromey  <tromey@adacore.com>

	* rust-exp.y (rust_parser::convert_ast_to_expression): Update.
	* parse.c (parser_state::push_symbol, parser_state::push_dollar):
	Update.
	* p-exp.y (variable): Update.
	* m2-exp.y (variable): Update.
	* go-exp.y (variable): Update.
	* expprint.c (dump_for_expression): New overload.
	* expop.h (check_objfile): New overload.
	(check_constant): New overload.
	(class var_value_operation): Use block_symbol.
	<get_symbol>: Rewrite.
	* eval.c (var_value_operation::evaluate)
	(var_value_operation::evaluate_funcall)
	(var_value_operation::evaluate_for_address)
	(var_value_operation::evaluate_for_address)
	(var_value_operation::evaluate_with_coercion)
	(var_value_operation::evaluate_for_sizeof)
	(var_value_operation::evaluate_for_cast): Update.
	* d-exp.y (PrimaryExpression): Update.
	* c-exp.y (variable): Update.
	* ax-gdb.c (var_value_operation::do_generate_ax): Update.
	* ada-lang.c (ada_var_value_operation::evaluate_for_cast)
	(ada_var_value_operation::evaluate)
	(ada_var_value_operation::resolve)
	(ada_funcall_operation::resolve): Update.
	* ada-exp.y (write_var_from_sym, write_object_renaming)
	(write_ambiguous_var, write_var_or_type, write_name_assoc)
	(maybe_overload): Update.
	* ada-exp.h (class ada_var_value_operation) <get_block>: Rewrite.
2021-04-15 10:05:00 -06:00
Tom Tromey
9c79936b3d Use bound_minimal_symbol in var_msym_value_operation
This changes var_msym_value_operation to use a bound_minimal_symbol
rather than separate minsym and objfile parameters.  The main benefit
of this is removing the possibly-confusing check_objfile overload for
a plain minimal symbol.

gdb/ChangeLog
2021-03-08  Tom Tromey  <tom@tromey.com>

	* parse.c (parser_state::push_symbol, parser_state::push_dollar):
	Update.
	* p-exp.y (variable): Update.
	* go-exp.y (variable): Update.
	* expprint.c (dump_for_expression): Use bound_minimal_symbol.
	Remove overload for objfile.
	* expop.h (eval_op_var_msym_value): Use bound_minimal_symbol
	parameter.
	(check_objfile): Likewise.
	(dump_for_expression): Likewise.  Remove overload for objfile.
	(class var_msym_value_operation): Use bound_minimal_symbol.
	* eval.c (eval_op_var_msym_value): Use bound_minimal_symbol
	parameter.
	(var_msym_value_operation::evaluate_for_address)
	(var_msym_value_operation::evaluate_for_sizeof)
	(var_msym_value_operation::evaluate_for_cast): Update.
	* d-exp.y (PrimaryExpression): Update.
	* c-exp.y (variable): Update.
	* ax-gdb.c (var_msym_value_operation::do_generate_ax): Update.
	* ada-lang.c (ada_var_msym_value_operation::evaluate_for_cast):
	Update.
	* ada-exp.y (write_var_or_type): Update.
2021-03-08 07:28:44 -07:00
Tom Tromey
1eaebe02cf Remove union exp_element
This removes union exp_element functions that either create such
elements or walk them.  struct expression no longer holds
exp_elements.  A couple of language_defn methods are also removed, as
they are obsolete.

Note that this patch also removes the print_expression code.  The only
in-tree caller of this was from dump_prefix_expression, which is only
called when expression debugging is enabled.  Implementing this would
involve a fair amount of code, and it seems to me that prefix dumping
is preferable anyway, as it is unambiguous.  So, I have not
reimplemented this feature.

gdb/ChangeLog
2021-03-08  Tom Tromey  <tom@tromey.com>

	* value.h (evaluate_subexp_with_coercion): Don't declare.
	* parse.c (exp_descriptor_standard): Remove.
	(expr_builder::expr_builder, expr_builder::release): Update.
	(expression::expression): Remove size_t parameter.
	(expression::~expression): Simplify.
	(expression::resize): Remove.
	(write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym)
	(write_exp_elt_msym, write_exp_elt_block, write_exp_elt_objfile)
	(write_exp_elt_longcst, write_exp_elt_floatcst)
	(write_exp_elt_type, write_exp_elt_intern, write_exp_string)
	(write_exp_string_vector, write_exp_bitstring): Remove.
	* p-lang.h (class pascal_language) <opcode_print_table,
	op_print_tab>: Remove.
	* p-lang.c (pascal_language::op_print_tab): Remove.
	* opencl-lang.c (class opencl_language) <opcode_print_table>:
	Remove.
	* objc-lang.c (objc_op_print_tab): Remove.
	(class objc_language) <opcode_print_table>: Remove.
	* m2-lang.h (class m2_language) <opcode_print_table,
	op_print_tab>: Remove.
	* m2-lang.c (m2_language::op_print_tab): Remove.
	* language.h (struct language_defn) <post_parser, expression_ops,
	opcode_print_table>: Remove.
	* language.c (language_defn::expression_ops)
	(auto_or_unknown_language::opcode_print_table): Remove.
	* go-lang.h (class go_language) <opcode_print_table,
	op_print_tab>: Remove.
	* go-lang.c (go_language::op_print_tab): Remove.
	* f-lang.h (class f_language) <opcode_print_table>: Remove
	<op_print_tab>: Remove.
	* f-lang.c (f_language::op_print_tab): Remove.
	* expression.h (union exp_element): Remove.
	(struct expression): Remove size_t parameter from constructor.
	<resize>: Remove.
	<first_opcode>: Update.
	<nelts, elts>: Remove.
	(EXP_ELEM_TO_BYTES, BYTES_TO_EXP_ELEM): Remove.
	(evaluate_subexp_standard, print_expression, op_string)
	(dump_raw_expression): Don't declare.
	* expprint.c (print_expression, print_subexp)
	(print_subexp_funcall, print_subexp_standard, op_string)
	(dump_raw_expression, dump_subexp, dump_subexp_body)
	(dump_subexp_body_funcall, dump_subexp_body_standard): Remove.
	(dump_prefix_expression): Update.
	* eval.c (evaluate_subexp): Remove.
	(evaluate_expression, evaluate_type): Update.
	(evaluate_subexpression_type): Remove.
	(fetch_subexp_value): Remove "pc" parameter.  Update.
	(extract_field_op, evaluate_struct_tuple, evaluate_funcall)
	(evaluate_subexp_standard, evaluate_subexp_for_address)
	(evaluate_subexp_with_coercion, evaluate_subexp_for_sizeof)
	(evaluate_subexp_for_cast): Remove.
	(parse_and_eval_type): Update.
	* dtrace-probe.c (dtrace_probe::compile_to_ax): Update.
	* d-lang.c (d_op_print_tab): Remove.
	(class d_language) <opcode_print_table>: Remove.
	* c-lang.h (c_op_print_tab): Don't declare.
	* c-lang.c (c_op_print_tab): Remove.
	(class c_language, class cplus_language, class asm_language, class
	minimal_language) <opcode_print_table>: Remove.
	* breakpoint.c (update_watchpoint, watchpoint_check)
	(watchpoint_exp_is_const, watch_command_1): Update.
	* ax-gdb.h (union exp_element): Don't declare.
	* ax-gdb.c (const_var_ref, const_expr, maybe_const_expr)
	(gen_repeat, gen_sizeof, gen_expr_for_cast, gen_expr)
	(gen_expr_binop_rest): Remove.
	(gen_trace_for_expr, gen_eval_for_expr, gen_printf): Update.
	* ada-lang.c (ada_op_print_tab): Remove.
	(class ada_language) <post_parser, opcode_print_table>: Remove.
2021-03-08 07:28:41 -07:00
Tom Tromey
413403fc34 Add an expr::operation_up to struct expression
This adds an expr::operation_up to struct expression, and then
modifies various parts of GDB to use this member when it is non-null.
The list of such spots was a bit surprising to me, and found only
after writing most of the code and then noticing what no longer
compiled.

In a few spots, new accessor methods are added to operation
subclasses, so that code that dissects an expression will work with
the new scheme.

After this change, code that constructs an expression can be switched
to the new form without breaking.

gdb/ChangeLog
2021-03-08  Tom Tromey  <tom@tromey.com>

	* ada-exp.h (class ada_var_value_operation) <get_symbol>: Remove;
	now in superclass.
	* value.h (fetch_subexp_value): Add "op" parameter.
	* value.c (init_if_undefined_command): Update.
	* tracepoint.c (validate_actionline, encode_actions_1): Update.
	* stap-probe.c (stap_probe::compile_to_ax): Update.
	* printcmd.c (set_command): Update.
	* ppc-linux-nat.c (ppc_linux_nat_target::check_condition):
	Update.
	* parser-defs.h (struct expr_builder) <set_operation>: New
	method.
	* parse.c (parse_exp_in_context, exp_uses_objfile): Update.
	* expression.h (struct expression) <first_opcode>: Update.
	<op>: New member.
	* expprint.c (dump_raw_expression, dump_prefix_expression):
	Update.
	* expop.h (class var_value_operation) <get_symbol>: New method.
	(class register_operation) <get_name>: New method.
	(class equal_operation): No longer a typedef, now a subclass.
	(class unop_memval_operation) <get_type>: New method.
	(class assign_operation) <get_lhs>: New method.
	(class unop_cast_operation) <get_type>: New method.
	* eval.c (evaluate_expression, evaluate_type)
	(evaluate_subexpression_type): Update.
	(fetch_subexp_value): Add "op" parameter.
	(parse_and_eval_type): Update.
	* dtrace-probe.c (dtrace_probe::compile_to_ax): Update.
	* breakpoint.c (update_watchpoint, watchpoint_check)
	(watchpoint_exp_is_const, watch_command_1): Update.
	* ax-gdb.c (gen_trace_for_expr, gen_eval_for_expr, gen_printf):
	Update.
2021-03-08 07:28:37 -07:00
Tom Tromey
5019124b1d Implement the "&&" and "||" operators
This implements the "&&" and "||" operators.

gdb/ChangeLog
2021-03-08  Tom Tromey  <tom@tromey.com>

	* expop.h (class logical_and_operation)
	(class logical_or_operation): New.
	* eval.c (logical_and_operation::evaluate)
	(logical_or_operation::evaluate): New methods.
	* ax-gdb.c (logical_and_operation::do_generate_ax)
	(logical_or_operation::do_generate_ax): New methods.
2021-03-08 07:28:28 -07:00
Tom Tromey
e82a5afced Introduce var_value_operation
This adds class var_value_operation, which implements OP_VAR_VALUE.

gdb/ChangeLog
2021-03-08  Tom Tromey  <tom@tromey.com>

	* expop.h (class var_value_operation): New.
	* eval.c (var_value_operation::evaluate)
	(var_value_operation::evaluate_for_address)
	(var_value_operation::evaluate_with_coercion)
	(var_value_operation::evaluate_for_sizeof)
	(var_value_operation::evaluate_for_cast): New methods.
	* ax-gdb.c (var_value_operation::do_generate_ax): New method.
2021-03-08 07:28:24 -07:00
Tom Tromey
292382f47e Introduce unop_cast_type_operation
This adds class unop_cast_type_operation, which implements
UNOP_CAST_TYPE.

gdb/ChangeLog
2021-03-08  Tom Tromey  <tom@tromey.com>

	* expop.h (class unop_cast_type_operation): New.
	* ax-gdb.c (unop_cast_type_operation::do_generate_ax): New
	method.
2021-03-08 07:28:24 -07:00
Tom Tromey
165a813a3a Introduce unop_cast_operation
This adds class unop_cast_operation, which implements UNOP_CAST.

gdb/ChangeLog
2021-03-08  Tom Tromey  <tom@tromey.com>

	* expop.h (class unop_cast_operation): New.
	* ax-gdb.c (unop_cast_operation::do_generate_ax): New method.
2021-03-08 07:28:24 -07:00
Tom Tromey
e5946e1604 Introduce assign_modify_operation
This adds class assign_modify_operation, which implements
BINOP_ASSIGN_MODIFY.

gdb/ChangeLog
2021-03-08  Tom Tromey  <tom@tromey.com>

	* expop.h (class assign_modify_operation): New.
	* eval.c (eval_binop_assign_modify): No longer static.
	* ax-gdb.c (assign_modify_operation::do_generate_ax): New method.
2021-03-08 07:28:24 -07:00
Tom Tromey
4078678289 Introduce assign_operation
This adds class assign_operation, which implements BINOP_ASSIGN.

gdb/ChangeLog
2021-03-08  Tom Tromey  <tom@tromey.com>

	* expop.h (class assign_operation): New.
	* ax-gdb.c (assign_operation::do_generate_ax): New method.
2021-03-08 07:28:23 -07:00
Tom Tromey
f6b4232691 Introduce op_this_operation
This adds class op_this_operation, which implements OP_THIS.

gdb/ChangeLog
2021-03-08  Tom Tromey  <tom@tromey.com>

	* expop.h (class op_this_operation): New.
	* ax-gdb.c (op_this_operation::do_generate_ax): New method.
2021-03-08 07:28:23 -07:00
Tom Tromey
cbc18219d3 Implement UNOP_MEMVAL and UNOP_MEMVAL_TYPE
This adds class unop_memval_operation and unop_memval_type_operation,
which implement UNOP_MEMVAL and UNOP_MEMVAL_TYPE.

gdb/ChangeLog
2021-03-08  Tom Tromey  <tom@tromey.com>

	* expop.h (class unop_memval_operation)
	(class unop_memval_type_operation): New.
	* eval.c (eval_op_memval): No longer static.
	(unop_memval_operation::evaluate_for_address)
	(unop_memval_type_operation::evaluate_for_address)
	(unop_memval_operation::evaluate_for_sizeof)
	(unop_memval_type_operation::evaluate_for_sizeof): New methods.
	* ax-gdb.c (unop_memval_operation::do_generate_ax)
	(unop_memval_type_operation::do_generate_ax): New methods.
2021-03-08 07:28:23 -07:00
Tom Tromey
85d23bda83 Introduce unop_sizeof_operation
This adds class unop_sizeof_operation, which implements UNOP_SIZEOF.

gdb/ChangeLog
2021-03-08  Tom Tromey  <tom@tromey.com>

	* expop.h (class unop_sizeof_operation): New.
	* ax-gdb.c (unop_sizeof_operation::do_generate_ax): New method.
2021-03-08 07:28:22 -07:00
Tom Tromey
14aff815df Introduce unop_addr_operation
This adds class unop_addr_operation, which implements UNOP_ADDR.

gdb/ChangeLog
2021-03-08  Tom Tromey  <tom@tromey.com>

	* expop.h (class unop_addr_operation): New.
	* ax-gdb.c (gen_expr_unop) <case UNOP_ADDR>: New.
2021-03-08 07:28:22 -07:00
Tom Tromey
876469ffa1 Introduce unop_ind_operation
This adds class unop_ind_operation, which implements UNOP_IND.

gdb/ChangeLog
2021-03-08  Tom Tromey  <tom@tromey.com>

	* expop.h (class unop_ind_base_operation)
	(class unop_ind_operation): New.
	* eval.c (eval_op_ind): No longer static.  Remove "op" parameter.
	(unop_ind_base_operation::evaluate_for_address)
	(unop_ind_base_operation::evaluate_for_sizeof): New method.
	* ax-gdb.c (gen_expr_unop) <case UNOP_IND>: New.
2021-03-08 07:28:21 -07:00
Tom Tromey
9307d17b7a Implement some unary operations
This introduces a couple of new template classes and then uses them to
implement some simple unary operations.

gdb/ChangeLog
2021-03-08  Tom Tromey  <tom@tromey.com>

	* expop.h (unary_ftype): New typedef.
	(unop_operation, usual_ax_binop_operation): New templates.
	(unary_plus_operation, unary_neg_operation)
	(unary_complement_operation, unary_logical_not_operation): New
	typedefs.
	* eval.c (eval_op_plus, eval_op_neg, eval_op_complement)
	(eval_op_lognot): No longer static.
	* ax-gdb.c (gen_expr_unop): New function.
2021-03-08 07:28:20 -07:00
Tom Tromey
ae64ba58b3 Introduce comma_operation
This adds class comma_operation, which implements BINOP_COMMA.

gdb/ChangeLog
2021-03-08  Tom Tromey  <tom@tromey.com>

	* ax-gdb.c (comma_operation::do_generate_ax): New method.
2021-03-08 07:28:20 -07:00
Tom Tromey
d4eff4c122 Introduce repeat_operation
This adds class repeat_operation, which implements BINOP_REPEAT.

gdb/ChangeLog
2021-03-08  Tom Tromey  <tom@tromey.com>

	* expop.h (class repeat_operation): New.
	* eval.c (eval_op_repeat): No longer static.  Remove "op"
	parameter.
	(evaluate_subexp_standard): Update.
	* ax-gdb.c (repeat_operation::do_generate_ax): New method.
2021-03-08 07:28:20 -07:00
Tom Tromey
9186293fd6 Introduce ternop_cond_operation
This adds class ternop_cond_operation, which implements TERNOP_COND.

gdb/ChangeLog
2021-03-08  Tom Tromey  <tom@tromey.com>

	* expop.h (class ternop_cond_operation): New.
	* ax-gdb.c (ternop_cond_operation::do_generate_ax): New method.
2021-03-08 07:28:17 -07:00
Tom Tromey
e6e01e16c5 Introduce internalvar_operation
This adds class internalvar_operation, which implements
OP_INTERNALVAR.

gdb/ChangeLog
2021-03-08  Tom Tromey  <tom@tromey.com>

	* expop.h (class internalvar_operation): New.
	* ax-gdb.c (internalvar_operation::do_generate_ax): New method.
2021-03-08 07:28:16 -07:00
Tom Tromey
55bdbff857 Introduce register_operation
This adds class register_operation, which implements OP_REGISTER.

gdb/ChangeLog
2021-03-08  Tom Tromey  <tom@tromey.com>

	* expop.h (class register_operation): New.
	* eval.c (eval_op_register): No longer static.
	* ax-gdb.c (register_operation::do_generate_ax): New method.
2021-03-08 07:28:16 -07:00
Tom Tromey
0c8effa32e Introduce var_msym_value_operation
This adds class var_msym_value_operation, which implements
OP_VAR_MSYM_VALUE.  A new method is added to class operation in order
to support a special case in minsym evaluation.

gdb/ChangeLog
2021-03-08  Tom Tromey  <tom@tromey.com>

	* expression.h (class operation) <set_outermost>: New method.
	* expop.h (class var_msym_value_operation): New.
	* eval.c (eval_op_var_msym_value): No longer static.
	(var_msym_value_operation::evaluate_for_address)
	(var_msym_value_operation::evaluate_for_sizeof)
	(var_msym_value_operation::evaluate_for_cast): New methods.
	* ax-gdb.c (var_msym_value_operation::do_generate_ax): New
	method.
2021-03-08 07:28:15 -07:00
Tom Tromey
d336c29e3f Introduce long_const_operation
This adds class long_const_operation, which holds a scalar constant.

gdb/ChangeLog
2021-03-08  Tom Tromey  <tom@tromey.com>

	* expop.h (class long_const_operation): New.
	* ax-gdb.c (long_const_operation::do_generate_ax): New method.
2021-03-08 07:28:15 -07:00
Tom Tromey
d5ab122c48 Introduce scope_operation
This adds class scope_operation, an implementation of OP_SCOPE.

gdb/ChangeLog
2021-03-08  Tom Tromey  <tom@tromey.com>

	* expop.h (class scope_operation): New.
	* eval.c (eval_op_scope): No longer static.
	(scope_operation::evaluate_for_address): New method.
	* ax-gdb.c (scope_operation::do_generate_ax): New method.
2021-03-08 07:28:14 -07:00