1999-04-16 01:35:26 +00:00
|
|
|
/* Print in infix form a struct expression.
|
2003-01-13 Andrew Cagney <ac131313@redhat.com>
* ax-gdb.c, c-valprint.c, charset.c, corefile.c: Update copyright.
* demangle.c, disasm.c, dwarf2cfi.c, dwarfread.c: Update copyright.
* elfread.c, eval.c, expprint.c, expression.h: Update copyright.
* f-typeprint.c, findvar.c, gcore.c, gdb_mbuild.sh: Update copyright.
* gdbtypes.h, gnu-v2-abi.c, inferior.h, inftarg.c: Update copyright.
* language.c, language.h, m32r-tdep.c: Update copyright.
* mn10200-tdep.c, scm-lang.c, scm-lang.h: Update copyright.
* somsolib.c, somsolib.h, symfile.c, symtab.h: Update copyright.
* thread-db.c, typeprint.c, utils.c, valarith.c: Update copyright.
* values.c, win32-nat.c, x86-64-linux-nat.c: Update copyright.
* x86-64-linux-tdep.c, z8k-tdep.c: Update copyright.
* cli/cli-decode.h, config/h8500/tm-h8500.h: Update copyright.
Index: mi/ChangeLog
2003-01-13 Andrew Cagney <ac131313@redhat.com>
* mi-cmd-env.c: Update copyright.
2003-01-14 00:49:06 +00:00
|
|
|
|
2024-01-12 15:30:44 +00:00
|
|
|
Copyright (C) 1986-2024 Free Software Foundation, Inc.
|
1999-04-16 01:35:26 +00:00
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
This file is part of GDB.
|
1999-04-16 01:35:26 +00:00
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-08-23 18:08:50 +00:00
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
1999-07-07 20:19:36 +00:00
|
|
|
(at your option) any later version.
|
1999-04-16 01:35:26 +00:00
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
1999-04-16 01:35:26 +00:00
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
You should have received a copy of the GNU General Public License
|
2007-08-23 18:08:50 +00:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
1999-04-16 01:35:26 +00:00
|
|
|
|
2019-04-06 13:38:10 -06:00
|
|
|
#include "symtab.h"
|
2019-04-02 20:04:24 -06:00
|
|
|
#include "gdbtypes.h"
|
2019-04-06 13:38:10 -06:00
|
|
|
#include "expression.h"
|
|
|
|
#include "value.h"
|
1999-04-16 01:35:26 +00:00
|
|
|
#include "language.h"
|
|
|
|
#include "parser-defs.h"
|
2023-09-19 20:34:23 -06:00
|
|
|
#include "user-regs.h"
|
2002-11-19 03:36:44 +00:00
|
|
|
#include "target.h"
|
2019-04-06 13:38:10 -06:00
|
|
|
#include "block.h"
|
|
|
|
#include "objfiles.h"
|
gdb
* varobj.c (value_get_print_value): Include valprint.h.
(value_get_print_value): Use get_formatted_print_options.
* value.h (struct value_print_options): Declare.
(value_print, val_print, common_val_print, val_print_string):
Update.
* value.c: Include valprint.h.
(show_values): Use get_user_print_options.
(show_convenience): Likewise.
* valprint.h (prettyprint_arrays, prettyprint_structs): Don't
declare.
(struct value_print_options): New type.
(vtblprint, unionprint, addressprint, objectprint, print_max,
inspect_it, repeat_count_threshold, output_format,
stop_print_at_null): Don't declare.
(user_print_options, get_user_print_options,
get_raw_print_options, get_formatted_print_options): Declare.
(print_array_indexes_p): Don't declare.
(maybe_print_array_index, val_print_array_elements): Update.
* valprint.c (print_max): Remove.
(user_print_options): New global.
(get_user_print_options, get_raw_print_options,
get_formatted_print_options): New functions.
(print_array_indexes, repeat_count_threshold, stop_print_at_null,
prettyprint_structs, prettyprint_arrays, unionprint,
addressprint): Remove.
(val_print): Remove format, deref_ref, pretty arguments; add
options. Update.
(common_val_print): Likewise.
(print_array_indexes_p): Remove.
(maybe_print_array_index): Remove format, pretty arguments; add
options. Update.
(val_print_array_elements): Remove format, deref_ref, pretty
arguments; add options. Update.
(val_print_string): Add options argument. Update.
(_initialize_valprint): Use user_print_options.
(output_format): Remove.
(set_output_radix_1): Use user_print_options.
* typeprint.c: Include valprint.h.
(objectprint): Don't declare.
(whatis_exp): Use get_user_print_options.
* tui/tui-regs.c: Include valprint.h.
(tui_register_format): Use get_formatted_print_options.
* tracepoint.c: Include valprint.h.
(addressprint): Don't declare.
(trace_mention): Use get_user_print_options.
(tracepoints_info): Likewise.
* stack.c (print_frame_args): Use get_raw_print_options.
(print_frame_info): Use get_user_print_options.
(print_frame): Likewise.
* sh64-tdep.c: Include valprint.h
(sh64_do_register): Use get_formatted_print_options.
* scm-valprint.c (scm_inferior_print): Remove format, deref_ref,
pretty arguments; add options.
(scm_scmlist_print): Likewise. Update.
(scm_scmval_print): Likewise.
(scm_val_print): Likewise.
(scm_value_print): Remove format, pretty arguments; add options.
Update.
* scm-lang.h (scm_value_print, scm_val_print, scm_scmval_print):
Update.
* scm-lang.c (scm_printstr): Add options argument.
* python/python-value.c: Include valprint.h.
(valpy_str): Use get_user_print_options.
* printcmd.c: Include valprint.h.
(addressprint): Don't declare.
(inspect_it): Remove.
(print_formatted): Remove format option; add options. Update.
(print_scalar_formatted): Likewise.
(print_address_demangle): Use get_user_print_options.
(do_examine): Use get_formatted_print_options.
(print_command_1): Likewise.
(output_command): Use get_formatted_print_options.
(do_one_display): Likewise.
(print_variable_value): Use get_user_print_options.
* p-valprint.c (pascal_val_print): Remove format, deref_ref,
pretty arguments; add options. Update.
(pascal_value_print): Remove format, pretty arguments; add
options. Update.
(vtblprint, objectprint): Don't declare.
(pascal_static_field_print): Remove.
(pascal_object_print_value_fields): Remove format, pretty
arguments; add options. Update.
(pascal_object_print_static_field): Likewise.
(_initialize_pascal_valprint): Use user_print_options. Update.
* p-lang.h (pascal_val_print, pascal_value_print,
pascal_printstr, pascal_object_print_value_fields): Update.
(vtblprint, static_field_print): Don't declare.
* p-lang.c (pascal_printstr): Add options argument. Update.
* objc-lang.c (objc_printstr): Add options argument. Update.
* mt-tdep.c: Include valprint.h.
(mt_registers_info): Use get_raw_print_options.
* mips-tdep.c: Include valprint.h.
(mips_print_fp_register): Use get_formatted_print_options.
(mips_print_register): Likewise.
* mi/mi-main.c: Include valprint.h.
(get_register): Use get_user_print_options.
(mi_cmd_data_evaluate_expression): Likewise.
(mi_cmd_data_read_memory): Use get_formatted_print_options.
* mi/mi-cmd-stack.c: Include valprint.h.
(list_args_or_locals): Use get_raw_print_options.
* m2-valprint.c (print_function_pointer_address): Add addressprint
argument.
(m2_print_long_set): Remove format, pretty arguments.
(m2_print_unbounded_array): Remove format, deref_ref, pretty
arguments; add options. Update.
(print_unpacked_pointer): Remove format argument; add options.
Now static. Update.
(print_variable_at_address): Remove format, deref_ref, pretty
arguments; add options. Update.
(m2_print_array_contents): Likewise.
(m2_val_print): Likewise.
* m2-lang.h (m2_val_print): Update.
* m2-lang.c (m2_printstr): Add options argument. Update.
* language.h (struct value_print_options): Declare.
(struct language_defn) <la_printstr>: Add options argument.
<la_val_print>: Remove format, deref_ref, pretty argument; add
options.
<la_value_print>: Remove format, pretty arguments; add options.
<la_print_array_index>: Likewise.
(LA_VAL_PRINT, LA_VALUE_PRINT, LA_PRINT_STRING,
LA_PRINT_ARRAY_INDEX): Update.
(default_print_array_index): Update.
* language.c (default_print_array_index): Remove format, pretty
arguments; add options. Update.
(unk_lang_printstr): Add options argument.
(unk_lang_val_print): Remove format, deref_ref, pretty arguments;
add options.
(unk_lang_value_print): Remove format, pretty arguments; add
options.
* jv-valprint.c (java_value_print): Remove format, pretty
arguments; add options. Update.
(java_print_value_fields): Likewise.
(java_val_print): Remove format, deref_ref, pretty arguments; add
options. Update.
* jv-lang.h (java_val_print, java_value_print): Declare.
* infcmd.c: Include valprint.h.
(print_return_value): Use get_raw_print_options.
(default_print_registers_info): Use get_user_print_options,
get_formatted_print_options.
(registers_info): Use get_formatted_print_options.
* gdbtypes.h (struct value_print_options): Declare.
(print_scalar_formatted): Update.
* f-valprint.c (f77_print_array_1): Remove format, deref_ref,
pretty arguments; add options. Update.
(f77_print_array): Likewise.
(f_val_print): Likewise.
* f-lang.h (f_val_print): Update.
* f-lang.c (f_printstr): Add options argument. Update.
(c_value_print): Update declaration.
* expprint.c: Include valprint.h.
(print_subexp_standard): Use get_raw_print_options,
get_user_print_options.
* eval.c: Include valprint.h.
(objectprint): Don't declare.
(evaluate_subexp_standard): Use get_user_print_options.
* cp-valprint.c (vtblprint, objectprint, static_field_print):
Remove.
(cp_print_value_fields): Remove format, pretty arguments; add
options. Update.
(cp_print_value): Likewise.
(cp_print_static_field): Likewise.
(_initialize_cp_valprint): Use user_print_options. Update.
* c-valprint.c (print_function_pointer_address): Add addressprint
argument.
(c_val_print): Remove format, deref_ref, pretty arguments; add
options. Update.
(c_value_print): Add options argument. Update.
* c-lang.h (c_val_print, c_value_print, c_printstr): Update.
(vtblprint, static_field_print): Don't declare.
(cp_print_value_fields): Update.
* c-lang.c (c_printstr): Add options argument. Update.
* breakpoint.c: Include valprint.h.
(addressprint): Don't declare.
(watchpoint_value_print): Use get_user_print_options.
(print_one_breakpoint_location): Likewise.
(breakpoint_1, print_it_catch_fork, print_it_catch_vfork, mention,
print_exception_catchpoint): Likewise.
* auxv.c (fprint_target_auxv): Don't declare addressprint. Use
get_user_print_options.
* ada-valprint.c (struct ada_val_print_args): Remove format,
deref_ref, and pretty; add options.
(print_optional_low_bound): Add options argument.
(val_print_packed_array_elements): Remove format and pretty
arguments; add options. Update.
(printstr): Add options argument. Update.
(ada_printstr): Likewise.
(ada_val_print): Remove format, deref_ref, pretty arguments; add
options argument. Update.
(ada_val_print_stub): Update.
(ada_val_print_array): Remove format, deref_ref, pretty arguments;
add options. Update.
(ada_val_print_1): Likewise.
(print_variant_part): Likewise.
(ada_value_print): Remove format, pretty arguments; add options.
Update.
(print_record): Likewise.
(print_field_values): Likewise.
* ada-lang.h (ada_val_print, ada_value_print, ada_printstr):
Update.
* ada-lang.c (ada_print_array_index): Add options argument; remove
format and pretty arguments.
(print_one_exception): Use get_user_print_options.
gdb/testsuite
* gdb.base/exprs.exp (test_expr): Add enum formatting tests.
2008-10-28 17:19:58 +00:00
|
|
|
#include "valprint.h"
|
Introduce metadata style
This introduces a new "metadata" style and changes many places in gdb
to use it. The idea here is to let the user distinguish gdb output
from output that (conceptually at least) comes directly from the
inferior. The newly-styled category includes text that gdb
traditionally surrounds in "<...>", like "<unavailable>".
I only added a single test for this. In many cases this output is
difficult to test. Also, while developing this errors in the
implementation of the new printf formats showed up as regressions.
gdb/ChangeLog
2019-10-01 Tom Tromey <tom@tromey.com>
* p-lang.c (pascal_printstr): Use metadata style.
* value.c (show_convenience): Use metadata style.
* valprint.c (valprint_check_validity, val_print_optimized_out)
(val_print_not_saved, val_print_unavailable)
(val_print_invalid_address, generic_val_print, val_print)
(value_check_printable, val_print_array_elements): Use metadata
style.
* ui-out.h (class ui_out) <field_fmt>: New overload.
<do_field_fmt>: Add style parameter.
* ui-out.c (ui_out::field_fmt): New overload.
* typeprint.c (type_print_unknown_return_type)
(val_print_not_allocated, val_print_not_associated): Use metadata
style.
* tui/tui-out.h (class tui_ui_out) <do_field_fmt>: Add style
parameter.
* tui/tui-out.c (tui_ui_out::do_field_fmt): Update.
* tracepoint.c (tvariables_info_1): Use metadata style.
* stack.c (print_frame_arg, print_frame_info, print_frame)
(info_frame_command_core): Use metadata style.
* skip.c (info_skip_command): Use metadata style.
* rust-lang.c (rust_print_enum): Use metadata style.
* python/py-prettyprint.c (print_stack_unless_memory_error): Use
metadata style.
* python/py-framefilter.c (py_print_single_arg): Use metadata
style.
* printcmd.c (do_one_display, print_variable_and_value): Use
metadata style.
* p-valprint.c (pascal_val_print)
(pascal_object_print_value_fields): Use metadata style.
* p-typeprint.c (pascal_type_print_base): Use metadata style.
* mi/mi-out.h (class mi_ui_out) <do_field_fmt>: Add style
parameter.
* mi/mi-out.c (mi_ui_out::do_field_fmt): Update.
* m2-valprint.c (m2_print_long_set): Use metadata style.
* m2-typeprint.c (m2_print_type): Use metadata style.
* infcmd.c (print_return_value_1): Use metadata style.
* gnu-v3-abi.c (print_one_vtable): Use metadata style.
* f-valprint.c (info_common_command_for_block): Use metadata
style.
* f-typeprint.c (f_type_print_base): Use metadata style.
* expprint.c (print_subexp_standard): Use metadata style.
* cp-valprint.c (cp_print_value_fields): Use metadata style.
* cli/cli-style.h (class cli_style_option): Add constructor.
(metadata_style): Declare.
* cli/cli-style.c (metadata_style): New global.
(_initialize_cli_style): Register metadata style.
* cli-out.h (class cli_ui_out) <do_field_fmt>: Add style
parameter.
* cli-out.c (cli_ui_out::do_field_fmt): Update.
* c-typeprint.c (c_type_print_base_struct_union)
(c_type_print_base_1): Use metadata style.
* breakpoint.c (watchpoint_value_print)
(print_one_breakpoint_location): Use metadata style.
* break-catch-syscall.c (print_one_catch_syscall): Use metadata
style.
* break-catch-sig.c (signal_catchpoint_print_one): Use metadata
style.
* ada-valprint.c (val_print_packed_array_elements, printstr)
(print_field_values, ada_val_print_ref, ada_val_print): Use
metadata style.
* ada-typeprint.c (print_array_type, ada_print_type): Use metadata
style.
* ada-tasks.c (print_ada_task_info, info_task): Use metadata
style.
* ada-lang.c (user_select_syms): Use metadata style.
gdb/testsuite/ChangeLog
2019-10-01 Tom Tromey <tom@tromey.com>
* lib/gdb-utils.exp (style): Handle "metadata" argument.
* gdb.base/style.exp: Add metadata style test.
2019-04-02 20:00:18 -06:00
|
|
|
#include "cli/cli-style.h"
|
2021-03-08 07:27:57 -07:00
|
|
|
#include "c-lang.h"
|
|
|
|
#include "expop.h"
|
Implement Ada assignment
Assignment is the most complicated Ada expression, because
implementing aggregate assignment involves several specialized
opcodes.
This patch does this implementation by introducing new abstract
classes that are used to represent the various parts of aggregate
assignment. This makes the code somewhat cleaner, and, by avoiding
the over-use of 'operation' subclasses, avoids the need for dissection
using dynamic_cast (though a few are still needed here).
I believe this patch fixes a latent bug in the handling of
aggregate_assign_from_choices. That code does:
if (op == OP_DISCRETE_RANGE)
{
choice_pos += 1;
lower = value_as_long (ada_evaluate_subexp (NULL, exp, pos,
EVAL_NORMAL));
upper = value_as_long (ada_evaluate_subexp (NULL, exp, pos,
EVAL_NORMAL));
}
However, I think 'choice_pos' should be used in the calls, rather than
'pos'.
gdb/ChangeLog
2021-03-08 Tom Tromey <tom@tromey.com>
* expprint.c (dump_for_expression): New overload.
* expop.h (check_objfile, dump_for_expression): Declare new
overloads.
* ada-lang.c (check_objfile): New overload.
(assign_component, ada_aggregate_component::uses_objfile)
(ada_aggregate_component::dump, ada_aggregate_component::assign)
(ada_aggregate_component::assign_aggregate)
(ada_positional_component::uses_objfile)
(ada_positional_component::dump, ada_positional_component::assign)
(ada_discrete_range_association::uses_objfile)
(ada_discrete_range_association::dump)
(ada_discrete_range_association::assign)
(ada_name_association::uses_objfile, ada_name_association::dump)
(ada_name_association::assign)
(ada_choices_component::uses_objfile, ada_choices_component::dump)
(ada_choices_component::assign)
(ada_others_component::uses_objfile, ada_others_component::dump)
(ada_others_component::assign, ada_assign_operation::evaluate):
New methods.
* ada-exp.h (ada_string_operation) <get_name>: New method.
(class ada_assign_operation): New.
(class ada_component): New.
(ada_component_up): New typedef.
(class ada_aggregate_operation, class ada_aggregate_component)
(class ada_positional_component, class ada_others_component)
(class ada_association): New.
(ada_association_up): New typedef.
(class ada_choices_component)
(class ada_discrete_range_association)
(class ada_name_association): New.
2021-03-08 07:27:57 -07:00
|
|
|
#include "ada-exp.h"
|
2019-04-06 13:38:10 -06:00
|
|
|
|
|
|
|
#include <ctype.h>
|
1999-04-16 01:35:26 +00:00
|
|
|
|
2022-08-05 08:09:57 +02:00
|
|
|
/* Meant to be used in debug sessions, so don't export it in a header file. */
|
|
|
|
extern void ATTRIBUTE_USED debug_exp (struct expression *exp);
|
|
|
|
|
|
|
|
/* Print EXP. */
|
|
|
|
|
|
|
|
void
|
|
|
|
ATTRIBUTE_USED
|
|
|
|
debug_exp (struct expression *exp)
|
|
|
|
{
|
2023-01-02 10:37:15 -07:00
|
|
|
exp->dump (gdb_stdlog);
|
2022-08-05 08:09:57 +02:00
|
|
|
gdb_flush (gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2021-03-08 07:27:57 -07:00
|
|
|
namespace expr
|
|
|
|
{
|
|
|
|
|
2023-01-21 14:00:05 -07:00
|
|
|
bool
|
|
|
|
check_objfile (const struct block *block, struct objfile *objfile)
|
|
|
|
{
|
2023-01-16 17:16:44 -07:00
|
|
|
return check_objfile (block->objfile (), objfile);
|
2023-01-21 14:00:05 -07:00
|
|
|
}
|
|
|
|
|
2021-03-08 07:27:57 -07:00
|
|
|
void
|
|
|
|
dump_for_expression (struct ui_file *stream, int depth, enum exp_opcode op)
|
|
|
|
{
|
2023-04-28 07:15:06 -06:00
|
|
|
gdb_printf (stream, _("%*sOperation: "), depth, "");
|
|
|
|
|
|
|
|
switch (op)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
gdb_printf (stream, "<unknown %d>", op);
|
|
|
|
break;
|
|
|
|
|
|
|
|
#define OP(name) \
|
|
|
|
case name: \
|
|
|
|
gdb_puts (#name, stream); \
|
|
|
|
break;
|
|
|
|
#include "std-operator.def"
|
|
|
|
#undef OP
|
|
|
|
}
|
|
|
|
|
|
|
|
gdb_puts ("\n", stream);
|
2021-03-08 07:27:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dump_for_expression (struct ui_file *stream, int depth, const std::string &str)
|
|
|
|
{
|
2022-01-02 11:46:15 -07:00
|
|
|
gdb_printf (stream, _("%*sString: %s\n"), depth, "", str.c_str ());
|
2021-03-08 07:27:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dump_for_expression (struct ui_file *stream, int depth, struct type *type)
|
|
|
|
{
|
2022-01-02 11:46:15 -07:00
|
|
|
gdb_printf (stream, _("%*sType: "), depth, "");
|
2021-03-08 07:27:57 -07:00
|
|
|
type_print (type, nullptr, stream, 0);
|
2022-01-02 11:46:15 -07:00
|
|
|
gdb_printf (stream, "\n");
|
2021-03-08 07:27:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dump_for_expression (struct ui_file *stream, int depth, CORE_ADDR addr)
|
|
|
|
{
|
2022-01-02 11:46:15 -07:00
|
|
|
gdb_printf (stream, _("%*sConstant: %s\n"), depth, "",
|
|
|
|
core_addr_to_string (addr));
|
2021-03-08 07:27:57 -07:00
|
|
|
}
|
|
|
|
|
2023-03-27 12:54:51 -06:00
|
|
|
void
|
|
|
|
dump_for_expression (struct ui_file *stream, int depth, const gdb_mpz &val)
|
|
|
|
{
|
|
|
|
gdb_printf (stream, _("%*sConstant: %s\n"), depth, "", val.str ().c_str ());
|
|
|
|
}
|
|
|
|
|
2021-03-08 07:27:57 -07:00
|
|
|
void
|
|
|
|
dump_for_expression (struct ui_file *stream, int depth, internalvar *ivar)
|
|
|
|
{
|
2022-01-02 11:46:15 -07:00
|
|
|
gdb_printf (stream, _("%*sInternalvar: $%s\n"), depth, "",
|
|
|
|
internalvar_name (ivar));
|
2021-03-08 07:27:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dump_for_expression (struct ui_file *stream, int depth, symbol *sym)
|
|
|
|
{
|
2022-01-02 11:46:15 -07:00
|
|
|
gdb_printf (stream, _("%*sSymbol: %s\n"), depth, "",
|
|
|
|
sym->print_name ());
|
2023-01-02 10:24:26 -07:00
|
|
|
dump_for_expression (stream, depth + 1, sym->type ());
|
2021-03-08 07:27:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2021-03-08 07:27:57 -07:00
|
|
|
dump_for_expression (struct ui_file *stream, int depth,
|
|
|
|
bound_minimal_symbol msym)
|
2021-03-08 07:27:57 -07:00
|
|
|
{
|
2022-01-02 11:46:15 -07:00
|
|
|
gdb_printf (stream, _("%*sMinsym %s in objfile %s\n"), depth, "",
|
|
|
|
msym.minsym->print_name (), objfile_name (msym.objfile));
|
2021-03-08 07:27:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dump_for_expression (struct ui_file *stream, int depth, const block *bl)
|
|
|
|
{
|
2022-01-02 11:46:15 -07:00
|
|
|
gdb_printf (stream, _("%*sBlock: %p\n"), depth, "", bl);
|
2021-03-08 07:27:57 -07:00
|
|
|
}
|
|
|
|
|
2021-04-15 10:05:00 -06:00
|
|
|
void
|
|
|
|
dump_for_expression (struct ui_file *stream, int depth,
|
|
|
|
const block_symbol &sym)
|
|
|
|
{
|
2022-01-02 11:46:15 -07:00
|
|
|
gdb_printf (stream, _("%*sBlock symbol:\n"), depth, "");
|
2021-04-15 10:05:00 -06:00
|
|
|
dump_for_expression (stream, depth + 1, sym.symbol);
|
|
|
|
dump_for_expression (stream, depth + 1, sym.block);
|
|
|
|
}
|
|
|
|
|
2021-03-08 07:27:57 -07:00
|
|
|
void
|
|
|
|
dump_for_expression (struct ui_file *stream, int depth,
|
|
|
|
type_instance_flags flags)
|
|
|
|
{
|
2022-01-02 11:46:15 -07:00
|
|
|
gdb_printf (stream, _("%*sType flags: "), depth, "");
|
2021-03-08 07:27:57 -07:00
|
|
|
if (flags & TYPE_INSTANCE_FLAG_CONST)
|
2022-01-02 11:36:44 -07:00
|
|
|
gdb_puts ("const ", stream);
|
2021-03-08 07:27:57 -07:00
|
|
|
if (flags & TYPE_INSTANCE_FLAG_VOLATILE)
|
2022-01-02 11:36:44 -07:00
|
|
|
gdb_puts ("volatile", stream);
|
2022-01-02 11:46:15 -07:00
|
|
|
gdb_printf (stream, "\n");
|
2021-03-08 07:27:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dump_for_expression (struct ui_file *stream, int depth,
|
|
|
|
enum c_string_type_values flags)
|
|
|
|
{
|
2022-01-02 11:46:15 -07:00
|
|
|
gdb_printf (stream, _("%*sC string flags: "), depth, "");
|
2021-03-08 07:27:57 -07:00
|
|
|
switch (flags & ~C_CHAR)
|
|
|
|
{
|
|
|
|
case C_WIDE_STRING:
|
2022-01-02 11:36:44 -07:00
|
|
|
gdb_puts (_("wide "), stream);
|
2021-03-08 07:27:57 -07:00
|
|
|
break;
|
|
|
|
case C_STRING_16:
|
2022-01-02 11:36:44 -07:00
|
|
|
gdb_puts (_("u16 "), stream);
|
2021-03-08 07:27:57 -07:00
|
|
|
break;
|
|
|
|
case C_STRING_32:
|
2022-01-02 11:36:44 -07:00
|
|
|
gdb_puts (_("u32 "), stream);
|
2021-03-08 07:27:57 -07:00
|
|
|
break;
|
|
|
|
default:
|
2022-01-02 11:36:44 -07:00
|
|
|
gdb_puts (_("ordinary "), stream);
|
2021-03-08 07:27:57 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((flags & C_CHAR) != 0)
|
2022-01-02 11:36:44 -07:00
|
|
|
gdb_puts (_("char"), stream);
|
2021-03-08 07:27:57 -07:00
|
|
|
else
|
2022-01-02 11:36:44 -07:00
|
|
|
gdb_puts (_("string"), stream);
|
|
|
|
gdb_puts ("\n", stream);
|
2021-03-08 07:27:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dump_for_expression (struct ui_file *stream, int depth,
|
|
|
|
enum range_flag flags)
|
|
|
|
{
|
2022-01-02 11:46:15 -07:00
|
|
|
gdb_printf (stream, _("%*sRange:"), depth, "");
|
2021-03-08 07:27:57 -07:00
|
|
|
if ((flags & RANGE_LOW_BOUND_DEFAULT) != 0)
|
2022-01-02 11:36:44 -07:00
|
|
|
gdb_puts (_("low-default "), stream);
|
2021-03-08 07:27:57 -07:00
|
|
|
if ((flags & RANGE_HIGH_BOUND_DEFAULT) != 0)
|
2022-01-02 11:36:44 -07:00
|
|
|
gdb_puts (_("high-default "), stream);
|
2021-03-08 07:27:57 -07:00
|
|
|
if ((flags & RANGE_HIGH_BOUND_EXCLUSIVE) != 0)
|
2022-01-02 11:36:44 -07:00
|
|
|
gdb_puts (_("high-exclusive "), stream);
|
2021-03-08 07:27:57 -07:00
|
|
|
if ((flags & RANGE_HAS_STRIDE) != 0)
|
2022-01-02 11:36:44 -07:00
|
|
|
gdb_puts (_("has-stride"), stream);
|
2022-01-02 11:46:15 -07:00
|
|
|
gdb_printf (stream, "\n");
|
2021-03-08 07:27:57 -07:00
|
|
|
}
|
|
|
|
|
Implement Ada assignment
Assignment is the most complicated Ada expression, because
implementing aggregate assignment involves several specialized
opcodes.
This patch does this implementation by introducing new abstract
classes that are used to represent the various parts of aggregate
assignment. This makes the code somewhat cleaner, and, by avoiding
the over-use of 'operation' subclasses, avoids the need for dissection
using dynamic_cast (though a few are still needed here).
I believe this patch fixes a latent bug in the handling of
aggregate_assign_from_choices. That code does:
if (op == OP_DISCRETE_RANGE)
{
choice_pos += 1;
lower = value_as_long (ada_evaluate_subexp (NULL, exp, pos,
EVAL_NORMAL));
upper = value_as_long (ada_evaluate_subexp (NULL, exp, pos,
EVAL_NORMAL));
}
However, I think 'choice_pos' should be used in the calls, rather than
'pos'.
gdb/ChangeLog
2021-03-08 Tom Tromey <tom@tromey.com>
* expprint.c (dump_for_expression): New overload.
* expop.h (check_objfile, dump_for_expression): Declare new
overloads.
* ada-lang.c (check_objfile): New overload.
(assign_component, ada_aggregate_component::uses_objfile)
(ada_aggregate_component::dump, ada_aggregate_component::assign)
(ada_aggregate_component::assign_aggregate)
(ada_positional_component::uses_objfile)
(ada_positional_component::dump, ada_positional_component::assign)
(ada_discrete_range_association::uses_objfile)
(ada_discrete_range_association::dump)
(ada_discrete_range_association::assign)
(ada_name_association::uses_objfile, ada_name_association::dump)
(ada_name_association::assign)
(ada_choices_component::uses_objfile, ada_choices_component::dump)
(ada_choices_component::assign)
(ada_others_component::uses_objfile, ada_others_component::dump)
(ada_others_component::assign, ada_assign_operation::evaluate):
New methods.
* ada-exp.h (ada_string_operation) <get_name>: New method.
(class ada_assign_operation): New.
(class ada_component): New.
(ada_component_up): New typedef.
(class ada_aggregate_operation, class ada_aggregate_component)
(class ada_positional_component, class ada_others_component)
(class ada_association): New.
(ada_association_up): New typedef.
(class ada_choices_component)
(class ada_discrete_range_association)
(class ada_name_association): New.
2021-03-08 07:27:57 -07:00
|
|
|
void
|
|
|
|
dump_for_expression (struct ui_file *stream, int depth,
|
|
|
|
const std::unique_ptr<ada_component> &comp)
|
|
|
|
{
|
|
|
|
comp->dump (stream, depth);
|
|
|
|
}
|
|
|
|
|
2021-03-08 07:27:57 -07:00
|
|
|
void
|
|
|
|
float_const_operation::dump (struct ui_file *stream, int depth) const
|
|
|
|
{
|
2022-01-02 11:46:15 -07:00
|
|
|
gdb_printf (stream, _("%*sFloat: "), depth, "");
|
2021-03-08 07:27:57 -07:00
|
|
|
print_floating (m_data.data (), m_type, stream);
|
2022-01-02 11:46:15 -07:00
|
|
|
gdb_printf (stream, "\n");
|
2021-03-08 07:27:57 -07:00
|
|
|
}
|
|
|
|
|
2021-03-08 07:27:57 -07:00
|
|
|
} /* namespace expr */
|