binutils-gdb/gdb/ada-exp.y

1465 lines
42 KiB
Plaintext
Raw Normal View History

2002-06-04 17:28:49 +02:00
/* YACC parser for Ada expressions, for GDB.
Copyright (C) 1986-2020 Free Software Foundation, Inc.
2002-06-04 17:28:49 +02:00
This file is part of GDB.
2002-06-04 17:28:49 +02: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
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
2002-06-04 17:28:49 +02: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.
2002-06-04 17:28:49 +02:00
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
2002-06-04 17:28:49 +02:00
/* Parse an Ada expression from text in a string,
and return the result as a struct expression pointer.
That structure contains arithmetic operations in reverse polish,
with constants represented by operations that are followed by special data.
See expression.h for the details of the format.
What is important here is that it can be built up sequentially
during the process of parsing; the lower levels of the tree always
come first in the result.
malloc's and realloc's in this file are transformed to
xmalloc and xrealloc respectively by the same sed command in the
makefile that remaps any other malloc/realloc inserted by the parser
generator. Doing this with #defines and trying to control the interaction
with include files (<malloc.h> and <stdlib.h> for example) just became
too messy, particularly when such includes can be inserted at random
times by the parser generator. */
2002-06-04 17:28:49 +02:00
%{
#include "defs.h"
#include <ctype.h>
#include "expression.h"
#include "value.h"
#include "parser-defs.h"
#include "language.h"
#include "ada-lang.h"
#include "bfd.h" /* Required by objfiles.h. */
#include "symfile.h" /* Required by objfiles.h. */
#include "objfiles.h" /* For have_full_symbols and have_partial_symbols */
#include "frame.h"
2003-02-19 David Carlton <carlton@math.stanford.edu> * Makefile.in (SFILES): Add block.c. (block_h): New. (COMMON_OBS): Add block.o. (block.o): New. (x86-64-tdep.o): Add $(block_h). (values.o, valops.o, tracepoint.o, symtab.o, symmisc.o, symfile.o) (stack.o, printcmd.o, p-exp.tab.o, parse.o, objfiles.o) (objc-exp.tab.o, objc-lang.o, nlmread.o, mips-tdep.o, mdebugread.o) (m2-exp.tab.o, linespec.o, jv-lang.o, jv-exp.tab.o, infcmd.o) (f-valprint.o, findvar.o, f-exp.tab.o, expprint.o, coffread.o) (c-exp.tab.o, buildsym.o, breakpoint.o, blockframe.o, ax-gdb.o) (alpha-tdep.o, ada-lang.o, ada-exp.tab.o, mi-cmd-stack.o): Ditto. * value.h: Add opaque declaration for struct block. * parser-defs.h, objc-lang.h, buildsym.h, breakpoint.h: Ditto. * ada-lang.h: Ditto. * x86-64-tdep.c: #include "block.h" * values.c, valops.c, tracepoint.c, symtab.c, symmisc.c: Ditto. * symfile.c, stack.c, printcmd.c, p-exp.y, parse.c: Ditto. * objfiles.c, objc-exp.y, objc-lang.c, nlmread.c: Ditto. * mips-tdep.c, mdebugread.c, m2-exp.y, linespec.c: Ditto. * jv-lang.c, jv-exp.y, infcmd.c, f-valprint.c: Ditto. * findvar.c, f-exp.y, expprint.c, coffread.c, c-exp.y: Ditto. * buildsym.c, breakpoint.c, blockframe.c, ax-gdb.c: Ditto. * alpha-tdep.c, ada-lang.c, ada-exp.y: Ditto. * blockframe.c (blockvector_for_pc_sect): Move to "block.c". (blockvector_for_pc, block_for_pc_sect, block_for_pc): Ditto. * symtab.c (block_function): Ditto. (contained_in): Ditto. * frame.h: Move block_for_pc and block_for_pc_sect declarations to block.h. Add opaque declaration for struct block. * symtab.h: Move block_function and contained_in declarations to block.h. Add opaque declarations for struct block, struct blockvector. (struct block): Move to block.h. (struct blockvector): Ditto. (BLOCK_START, BLOCK_END, BLOCK_FUNCTION, BLOCK_SUPERBLOCK) (BLOCK_GCC_COMPILED, BLOCK_HASHTABLE, BLOCK_NSYMS, BLOCK_SYM) (BLOCK_BUCKETS, BLOCK_BUCKET, BLOCK_HASHTABLE_SIZE) (ALL_BLOCK_SYMBOLS, BLOCK_SHOULD_SORT, BLOCKVECTOR_NBLOCKS) (BLOCKVECTOR_BLOCK, GLOBAL_BLOCK, STATIC_BLOCK, FIRST_LOCAL_BLOCK): Ditto. * block.c: New file. * block.h: New file. 2003-02-19 David Carlton <carlton@math.stanford.edu> * mi-cmd-stack.c: #include "block.h"
2003-02-20 01:01:07 +01:00
#include "block.h"
2002-06-04 17:28:49 +02:00
#define parse_type(ps) builtin_type (ps->gdbarch ())
Centralize yacc interface names remapping (yyparse, yylex, yyerror, etc) This factors out all the yy-variables remapping to a single file, instead of each parser having to do the same, with different prefixes. With this, a parser just needs to define the prefix they want and include yy-remap.h, which does the dirty job. Note this renames the c_error, ada_error, etc. functions. Writing the remapping pattern as: #define yyerror GDB_YY_REMAP (error) instead of: #define yyerror GDB_YY_REMAP (yyerror) would have avoided the renaming. However, that would be problematic if we have a macro 'foo' in scope, when we write: #define yyfoo GDB_YY_REMAP (foo) as that would expand 'foo'. The c_yyerror etc. naming end ups indicating that this is a yacc related function more clearly, so feels like a good change, anyway. gdb/ChangeLog: 2016-04-22 Pedro Alves <palves@redhat.com> * ada-exp.y: Remove all yy symbol remappings. (GDB_YY_REMAP_PREFIX): Define. Include "yy-remap.h". * ada-lang.c (ada_language_defn): Adjust. * ada-lang.h (ada_error): Rename to ... (ada_yyerror): ... this. * c-exp.y: Remove all yy symbol remappings. (GDB_YY_REMAP_PREFIX): Define. Include "yy-remap.h". * c-lang.c (c_language_defn, cplus_language_defn) (asm_language_defn, minimal_language_defn): Adjust. * c-lang.h (c_error): Rename to ... (c_yyerror): ... this. * d-exp.y: Remove all yy symbol remappings. (GDB_YY_REMAP_PREFIX): Define. Include "yy-remap.h". * d-lang.c (d_language_defn): Adjust. * d-lang.h (d_error): Rename to ... (d_yyerror): ... this. * f-exp.y: Remove all yy symbol remappings. (GDB_YY_REMAP_PREFIX): Define. Include "yy-remap.h". * f-lang.c (f_language_defn): Adjust. * f-lang.h (f_error): Rename to ... (f_yyerror): ... this. * go-exp.y: Remove all yy symbol remappings. (GDB_YY_REMAP_PREFIX): Define. Include "yy-remap.h". * go-lang.c (go_language_defn): Adjust. * go-lang.h (go_error): Rename to ... (go_yyerror): ... this. * jv-exp.y: Remove all yy symbol remappings. (GDB_YY_REMAP_PREFIX): Define. Include "yy-remap.h". * jv-lang.c (java_language_defn): Adjust. * jv-lang.h (java_error): Rename to ... (java_yyerror): ... this. * m2-exp.y: Remove all yy symbol remappings. (GDB_YY_REMAP_PREFIX): Define. Include "yy-remap.h". * m2-lang.c (m2_language_defn): Adjust. * m2-lang.h (m2_error): Rename to ... (m2_yyerror): ... this. * objc-exp.y: Remove all yy symbol remappings. (GDB_YY_REMAP_PREFIX): Define. Include "yy-remap.h". * objc-lang.c (objc_language_defn): Adjust. * opencl-lang.c (opencl_language_defn): Adjust. * p-exp.y: Remove all yy symbol remappings. (GDB_YY_REMAP_PREFIX): Define. Include "yy-remap.h". * p-lang.c (pascal_language_defn): Adjust. * p-lang.h (pascal_error): Rename to ... (pascal_yyerror): ... this. * yy-remap.h: New file.
2016-04-22 17:40:33 +02:00
/* Remap normal yacc parser interface names (yyparse, yylex, yyerror,
etc). */
#define GDB_YY_REMAP_PREFIX ada_
#include "yy-remap.h"
2002-06-04 17:28:49 +02:00
struct name_info {
struct symbol *sym;
struct minimal_symbol *msym;
constify struct block in some places This makes some spots in gdb, particularly general_symbol_info, use a "const struct block", then fixes the fallout. The justification is that, ordinarily, blocks ought to be readonly. Note though that we can't add "const" in the blockvector due to block relocation. This can be done once blocks are made independent of the program space. 2014-06-18 Tom Tromey <tromey@redhat.com> * varobj.c (varobj_create): Update. * valops.c (value_of_this): Update. * tracepoint.c (add_local_symbols, scope_info): Update. * symtab.h (struct general_symbol_info) <block>: Now const. * symtab.c (skip_prologue_sal) (default_make_symbol_completion_list_break_on) (skip_prologue_using_sal): Update. * stack.h (iterate_over_block_locals) (iterate_over_block_local_vars): Update. * stack.c (print_frame_args): Update. (iterate_over_block_locals, iterate_over_block_local_vars): Make parameter const. (get_selected_block): Make return type const. * python/py-frame.c (frapy_block): Update. * python/py-block.c (gdbpy_block_for_pc): Update. * p-exp.y (%union) <bval>: Now const. * mi/mi-cmd-stack.c (list_args_or_locals): Update. * mdebugread.c (mylookup_symbol, parse_procedure): Update. * m2-exp.y (%union) <bval>: Now const. * linespec.c (get_current_search_block): Make return type const. (create_sals_line_offset, find_label_symbols): Update. * inline-frame.c (inline_frame_sniffer, skip_inline_frames): Update. (block_starting_point_at): Make "block" const. * infrun.c (insert_exception_resume_breakpoint): Make "b" const. (check_exception_resume): Update. * guile/scm-frame.c (gdbscm_frame_block): Update. * guile/scm-block.c (gdbscm_lookup_block): Update. * frame.h (get_frame_block): Update. (get_selected_block): Make return type const. * frame.c (frame_id_inner): Update. * f-valprint.c (info_common_command_for_block) (info_common_command): Update. * dwarf2loc.c (dwarf2_find_location_expression) (dwarf_expr_frame_base, dwarf2_compile_expr_to_ax) (locexpr_describe_location_piece): Update. * c-exp.y (%union) <bval>: Now const. * breakpoint.c (resolve_sal_pc): Update. * blockframe.c (get_frame_block):Make return type const. (get_pc_function_start, get_frame_function, find_pc_sect_function) (block_innermost_frame): Update. * block.h (blockvector_for_pc, blockvector_for_pc_sect) (block_for_pc, block_for_pc_sect): Update. * block.c (blockvector_for_pc_sect, blockvector_for_pc): Make 'pblock' const. (block_for_pc_sect, block_for_pc): Make return type const. * ax-gdb.c (gen_expr): Update. * alpha-mdebug-tdep.c (find_proc_desc): Update. * ada-lang.c (ada_read_renaming_var_value): Make 'block' const. (ada_make_symbol_completion_list, ada_add_exceptions_from_frame) (ada_read_var_value): Update. * ada-exp.y (struct name_info) <block>: Now const. (%union): Likewise. (block_lookup): Constify.
2013-03-12 16:51:37 +01:00
const struct block *block;
2002-06-04 17:28:49 +02:00
struct stoken stoken;
};
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
/* The state of the parser, used internally when we are parsing the
expression. */
static struct parser_state *pstate = NULL;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
static struct stoken empty_stoken = { "", 0 };
2002-06-04 17:28:49 +02:00
/* If expression is in the context of TYPE'(...), then TYPE, else
* NULL. */
static struct type *type_qualifier;
2002-06-04 17:28:49 +02:00
int yyparse (void);
static int yylex (void);
Remove la_error While working on the parser code, I noticed that yyerror is exported from each parser. It is used by this code in parse.c: TRY { if (lang->la_parser (&ps)) lang->la_error (NULL); } However, it seems to me that la_error will never be called here, because in every case, la_parser throws an exception on error -- each implementation of yyerror just calls error. So, this patch removes la_error and makes all the yyerror functions static. This is handy primarily because it makes it simpler to make the expression parsers pure. Tested by the buildbot. gdb/ChangeLog 2018-06-18 Tom Tromey <tom@tromey.com> * rust-lang.h (rust_yyerror): Don't declare. * rust-lang.c (rust_language_defn): Update. * rust-exp.y (yyerror): Now static. * parse.c (parse_exp_in_context_1): Update. * p-lang.h (p_yyerror): Don't declare. * p-lang.c (p_language_defn): Update. * p-exp.y (yyerror): Now static. * opencl-lang.c (opencl_language_defn): Update. * objc-lang.c (objc_language_defn): Update. * m2-lang.h (m2_yyerror): Don't declare. * m2-lang.c (m2_language_defn): Update. * m2-exp.y (yyerror): Now static. * language.h (struct language_defn) <la_error>: Remove. * language.c (unk_lang_error): Remove. (unknown_language_defn, auto_language_defn): Remove. * go-lang.h (go_yyerror): Don't declare. * go-lang.c (go_language_defn): Update. * go-exp.y (yyerror): Now static. * f-lang.h (f_yyerror): Don't declare. * f-lang.c (f_language_defn): Update. * f-exp.y (yyerror): Now static. * d-lang.h (d_yyerror): Don't declare. * d-lang.c (d_language_defn): Update. * d-exp.y (yyerror): Now static. * c-lang.h (c_yyerror): Don't declare. * c-lang.c (c_language_defn, cplus_language_defn) (asm_language_defn, minimal_language_defn): Update. * c-exp.y (yyerror): Now static. * ada-lang.h (ada_yyerror): Don't declare. * ada-lang.c (ada_language_defn): Update. * ada-exp.y (yyerror): Now static.
2018-06-02 07:02:37 +02:00
static void yyerror (const char *);
2002-06-04 17:28:49 +02:00
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
static void write_int (struct parser_state *, LONGEST, struct type *);
2002-06-04 17:28:49 +02:00
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
static void write_object_renaming (struct parser_state *,
const struct block *, const char *, int,
* ada-lang.h (ada_renaming_category): New enumerated type. (ada_lookup_encoded_symbol): Declare. (ada_parse_renaming): Declare. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete declarations. * ada-lang.c (ada_parse_renaming): New function to concentrate extraction of information from renaming symbols. (parse_old_style_renaming): New function to concentrate extraction of old-style (purely type-based) renaming information. (renaming_is_visible): Rename to... (old_renaming_is_invisible): Rename and change sense of renaming_is_visible. (remove_out_of_scope_renamings): Rename to... (remove_irrelevant_renamings): Renames remove_out_of_scope_renamings and augments with additional logic to handle cases where the same object renaming is encoded both as a reference variable and an encoded renaming. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete definitions. (ada_lookup_encoded_symbol): New function factored out of ada_lookup_symbol. (ada_lookup_symbol): Reimplement to call ada_lookup_encoded_symbol. (wild_match): Don't reject perfect match of prefix. (ada_find_renaming_symbol): Factor old-style renaming logic into find_old_style_renaming_symbol. (find_old_style_renaming_symbol): New name for content of old ada_find_renaming_symbol. (ada_prefer_type): Reimplement not to use ada_renaming_type. * ada-exp.y (write_object_renaming): Change interface. Reimplement to use new arguments and ada_parse_renaming. Correct blocks used to find array index. (write_var_or_type): Reimplement to use ada_parse_renaming.
2007-12-21 12:50:11 +01:00
const char *, int);
2002-06-04 17:28:49 +02:00
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
static struct type* write_var_or_type (struct parser_state *,
const struct block *, struct stoken);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
static void write_name_assoc (struct parser_state *, struct stoken);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
static void write_exp_op_with_string (struct parser_state *, enum exp_opcode,
struct stoken);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
constify struct block in some places This makes some spots in gdb, particularly general_symbol_info, use a "const struct block", then fixes the fallout. The justification is that, ordinarily, blocks ought to be readonly. Note though that we can't add "const" in the blockvector due to block relocation. This can be done once blocks are made independent of the program space. 2014-06-18 Tom Tromey <tromey@redhat.com> * varobj.c (varobj_create): Update. * valops.c (value_of_this): Update. * tracepoint.c (add_local_symbols, scope_info): Update. * symtab.h (struct general_symbol_info) <block>: Now const. * symtab.c (skip_prologue_sal) (default_make_symbol_completion_list_break_on) (skip_prologue_using_sal): Update. * stack.h (iterate_over_block_locals) (iterate_over_block_local_vars): Update. * stack.c (print_frame_args): Update. (iterate_over_block_locals, iterate_over_block_local_vars): Make parameter const. (get_selected_block): Make return type const. * python/py-frame.c (frapy_block): Update. * python/py-block.c (gdbpy_block_for_pc): Update. * p-exp.y (%union) <bval>: Now const. * mi/mi-cmd-stack.c (list_args_or_locals): Update. * mdebugread.c (mylookup_symbol, parse_procedure): Update. * m2-exp.y (%union) <bval>: Now const. * linespec.c (get_current_search_block): Make return type const. (create_sals_line_offset, find_label_symbols): Update. * inline-frame.c (inline_frame_sniffer, skip_inline_frames): Update. (block_starting_point_at): Make "block" const. * infrun.c (insert_exception_resume_breakpoint): Make "b" const. (check_exception_resume): Update. * guile/scm-frame.c (gdbscm_frame_block): Update. * guile/scm-block.c (gdbscm_lookup_block): Update. * frame.h (get_frame_block): Update. (get_selected_block): Make return type const. * frame.c (frame_id_inner): Update. * f-valprint.c (info_common_command_for_block) (info_common_command): Update. * dwarf2loc.c (dwarf2_find_location_expression) (dwarf_expr_frame_base, dwarf2_compile_expr_to_ax) (locexpr_describe_location_piece): Update. * c-exp.y (%union) <bval>: Now const. * breakpoint.c (resolve_sal_pc): Update. * blockframe.c (get_frame_block):Make return type const. (get_pc_function_start, get_frame_function, find_pc_sect_function) (block_innermost_frame): Update. * block.h (blockvector_for_pc, blockvector_for_pc_sect) (block_for_pc, block_for_pc_sect): Update. * block.c (blockvector_for_pc_sect, blockvector_for_pc): Make 'pblock' const. (block_for_pc_sect, block_for_pc): Make return type const. * ax-gdb.c (gen_expr): Update. * alpha-mdebug-tdep.c (find_proc_desc): Update. * ada-lang.c (ada_read_renaming_var_value): Make 'block' const. (ada_make_symbol_completion_list, ada_add_exceptions_from_frame) (ada_read_var_value): Update. * ada-exp.y (struct name_info) <block>: Now const. (%union): Likewise. (block_lookup): Constify.
2013-03-12 16:51:37 +01:00
static const struct block *block_lookup (const struct block *, const char *);
2002-06-04 17:28:49 +02:00
static LONGEST convert_char_literal (struct type *, LONGEST);
* ada-exp.y (type_int): New function to add layer of abstraction around references to expression types. (type_long): Ditto. (type_long_long): Ditto. (type_float): Ditto. (type_double): Ditto. (type_long_double): Ditto. (type_char): Ditto. (type_system_address): Ditto. (simple_exp): Use type_* functions in place of builtin_* variables. (exp): Ditto. (write_var_from_name): Ditto. (write_object_renaming): Ditto. * ada-lang.c (ada_create_fundamental_type): Remove redundant declaration. (build_ada_types): Remove, replacing with... (ada_language_arch_info): New function to initialize primitive type vector in language_arch_info. (ada_array_length): Remove use of builtin_type_ada_int. (value_pos_atr): Ditto. (ada_evaluate_subexp): Ditto. (builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long, builtin_type_ada_long_long, builtin_type_ada_char, builtin_type_ada_float, builtin_type_ada_double, builtin_type_ada_long_double, builtin_type_ada_natural, builtin_type_ada_positive, builtin_type_ada_system_address): Remove. (ada_builtin_types): Remove. (ada_language_defn): Remove entries for la_builtin_type_vector and string_char_type and use ada_language_arch_info. (_initialize_ada_language): Do type-vector initialization along the lines of c-lang.c. (ada_create_fundamental_type): Break up line. (ada_dump_symtab): Remove unused function. (enum ada_primitive_types): Define. * ada-lang.h (builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long,builtin_type_ada_long_long,builtin_type_ada_char, builtin_type_ada_float, builtin_type_ada_double, builtin_type_ada_long_double, builtin_type_ada_natural, builtin_type_ada_positive, builtin_type_ada_system_address): Remove. * ada-lex.l: Use type_* functions in place of builtin_* variables. (processInt): Ditto. (processReal): Ditto. (name_lookup): Ditto. * ada-typeprint.c (print_range): Use builtin_type_int, not builtin_type_ada_int.
2004-09-19 00:23:23 +02:00
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
static void write_ambiguous_var (struct parser_state *,
const struct block *, char *, int);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
static struct type *type_int (struct parser_state *);
* ada-exp.y (type_int): New function to add layer of abstraction around references to expression types. (type_long): Ditto. (type_long_long): Ditto. (type_float): Ditto. (type_double): Ditto. (type_long_double): Ditto. (type_char): Ditto. (type_system_address): Ditto. (simple_exp): Use type_* functions in place of builtin_* variables. (exp): Ditto. (write_var_from_name): Ditto. (write_object_renaming): Ditto. * ada-lang.c (ada_create_fundamental_type): Remove redundant declaration. (build_ada_types): Remove, replacing with... (ada_language_arch_info): New function to initialize primitive type vector in language_arch_info. (ada_array_length): Remove use of builtin_type_ada_int. (value_pos_atr): Ditto. (ada_evaluate_subexp): Ditto. (builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long, builtin_type_ada_long_long, builtin_type_ada_char, builtin_type_ada_float, builtin_type_ada_double, builtin_type_ada_long_double, builtin_type_ada_natural, builtin_type_ada_positive, builtin_type_ada_system_address): Remove. (ada_builtin_types): Remove. (ada_language_defn): Remove entries for la_builtin_type_vector and string_char_type and use ada_language_arch_info. (_initialize_ada_language): Do type-vector initialization along the lines of c-lang.c. (ada_create_fundamental_type): Break up line. (ada_dump_symtab): Remove unused function. (enum ada_primitive_types): Define. * ada-lang.h (builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long,builtin_type_ada_long_long,builtin_type_ada_char, builtin_type_ada_float, builtin_type_ada_double, builtin_type_ada_long_double, builtin_type_ada_natural, builtin_type_ada_positive, builtin_type_ada_system_address): Remove. * ada-lex.l: Use type_* functions in place of builtin_* variables. (processInt): Ditto. (processReal): Ditto. (name_lookup): Ditto. * ada-typeprint.c (print_range): Use builtin_type_int, not builtin_type_ada_int.
2004-09-19 00:23:23 +02:00
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
static struct type *type_long (struct parser_state *);
* ada-exp.y (type_int): New function to add layer of abstraction around references to expression types. (type_long): Ditto. (type_long_long): Ditto. (type_float): Ditto. (type_double): Ditto. (type_long_double): Ditto. (type_char): Ditto. (type_system_address): Ditto. (simple_exp): Use type_* functions in place of builtin_* variables. (exp): Ditto. (write_var_from_name): Ditto. (write_object_renaming): Ditto. * ada-lang.c (ada_create_fundamental_type): Remove redundant declaration. (build_ada_types): Remove, replacing with... (ada_language_arch_info): New function to initialize primitive type vector in language_arch_info. (ada_array_length): Remove use of builtin_type_ada_int. (value_pos_atr): Ditto. (ada_evaluate_subexp): Ditto. (builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long, builtin_type_ada_long_long, builtin_type_ada_char, builtin_type_ada_float, builtin_type_ada_double, builtin_type_ada_long_double, builtin_type_ada_natural, builtin_type_ada_positive, builtin_type_ada_system_address): Remove. (ada_builtin_types): Remove. (ada_language_defn): Remove entries for la_builtin_type_vector and string_char_type and use ada_language_arch_info. (_initialize_ada_language): Do type-vector initialization along the lines of c-lang.c. (ada_create_fundamental_type): Break up line. (ada_dump_symtab): Remove unused function. (enum ada_primitive_types): Define. * ada-lang.h (builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long,builtin_type_ada_long_long,builtin_type_ada_char, builtin_type_ada_float, builtin_type_ada_double, builtin_type_ada_long_double, builtin_type_ada_natural, builtin_type_ada_positive, builtin_type_ada_system_address): Remove. * ada-lex.l: Use type_* functions in place of builtin_* variables. (processInt): Ditto. (processReal): Ditto. (name_lookup): Ditto. * ada-typeprint.c (print_range): Use builtin_type_int, not builtin_type_ada_int.
2004-09-19 00:23:23 +02:00
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
static struct type *type_long_long (struct parser_state *);
* ada-exp.y (type_int): New function to add layer of abstraction around references to expression types. (type_long): Ditto. (type_long_long): Ditto. (type_float): Ditto. (type_double): Ditto. (type_long_double): Ditto. (type_char): Ditto. (type_system_address): Ditto. (simple_exp): Use type_* functions in place of builtin_* variables. (exp): Ditto. (write_var_from_name): Ditto. (write_object_renaming): Ditto. * ada-lang.c (ada_create_fundamental_type): Remove redundant declaration. (build_ada_types): Remove, replacing with... (ada_language_arch_info): New function to initialize primitive type vector in language_arch_info. (ada_array_length): Remove use of builtin_type_ada_int. (value_pos_atr): Ditto. (ada_evaluate_subexp): Ditto. (builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long, builtin_type_ada_long_long, builtin_type_ada_char, builtin_type_ada_float, builtin_type_ada_double, builtin_type_ada_long_double, builtin_type_ada_natural, builtin_type_ada_positive, builtin_type_ada_system_address): Remove. (ada_builtin_types): Remove. (ada_language_defn): Remove entries for la_builtin_type_vector and string_char_type and use ada_language_arch_info. (_initialize_ada_language): Do type-vector initialization along the lines of c-lang.c. (ada_create_fundamental_type): Break up line. (ada_dump_symtab): Remove unused function. (enum ada_primitive_types): Define. * ada-lang.h (builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long,builtin_type_ada_long_long,builtin_type_ada_char, builtin_type_ada_float, builtin_type_ada_double, builtin_type_ada_long_double, builtin_type_ada_natural, builtin_type_ada_positive, builtin_type_ada_system_address): Remove. * ada-lex.l: Use type_* functions in place of builtin_* variables. (processInt): Ditto. (processReal): Ditto. (name_lookup): Ditto. * ada-typeprint.c (print_range): Use builtin_type_int, not builtin_type_ada_int.
2004-09-19 00:23:23 +02:00
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
static struct type *type_long_double (struct parser_state *);
* ada-exp.y (type_int): New function to add layer of abstraction around references to expression types. (type_long): Ditto. (type_long_long): Ditto. (type_float): Ditto. (type_double): Ditto. (type_long_double): Ditto. (type_char): Ditto. (type_system_address): Ditto. (simple_exp): Use type_* functions in place of builtin_* variables. (exp): Ditto. (write_var_from_name): Ditto. (write_object_renaming): Ditto. * ada-lang.c (ada_create_fundamental_type): Remove redundant declaration. (build_ada_types): Remove, replacing with... (ada_language_arch_info): New function to initialize primitive type vector in language_arch_info. (ada_array_length): Remove use of builtin_type_ada_int. (value_pos_atr): Ditto. (ada_evaluate_subexp): Ditto. (builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long, builtin_type_ada_long_long, builtin_type_ada_char, builtin_type_ada_float, builtin_type_ada_double, builtin_type_ada_long_double, builtin_type_ada_natural, builtin_type_ada_positive, builtin_type_ada_system_address): Remove. (ada_builtin_types): Remove. (ada_language_defn): Remove entries for la_builtin_type_vector and string_char_type and use ada_language_arch_info. (_initialize_ada_language): Do type-vector initialization along the lines of c-lang.c. (ada_create_fundamental_type): Break up line. (ada_dump_symtab): Remove unused function. (enum ada_primitive_types): Define. * ada-lang.h (builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long,builtin_type_ada_long_long,builtin_type_ada_char, builtin_type_ada_float, builtin_type_ada_double, builtin_type_ada_long_double, builtin_type_ada_natural, builtin_type_ada_positive, builtin_type_ada_system_address): Remove. * ada-lex.l: Use type_* functions in place of builtin_* variables. (processInt): Ditto. (processReal): Ditto. (name_lookup): Ditto. * ada-typeprint.c (print_range): Use builtin_type_int, not builtin_type_ada_int.
2004-09-19 00:23:23 +02:00
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
static struct type *type_char (struct parser_state *);
* ada-exp.y (type_int): New function to add layer of abstraction around references to expression types. (type_long): Ditto. (type_long_long): Ditto. (type_float): Ditto. (type_double): Ditto. (type_long_double): Ditto. (type_char): Ditto. (type_system_address): Ditto. (simple_exp): Use type_* functions in place of builtin_* variables. (exp): Ditto. (write_var_from_name): Ditto. (write_object_renaming): Ditto. * ada-lang.c (ada_create_fundamental_type): Remove redundant declaration. (build_ada_types): Remove, replacing with... (ada_language_arch_info): New function to initialize primitive type vector in language_arch_info. (ada_array_length): Remove use of builtin_type_ada_int. (value_pos_atr): Ditto. (ada_evaluate_subexp): Ditto. (builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long, builtin_type_ada_long_long, builtin_type_ada_char, builtin_type_ada_float, builtin_type_ada_double, builtin_type_ada_long_double, builtin_type_ada_natural, builtin_type_ada_positive, builtin_type_ada_system_address): Remove. (ada_builtin_types): Remove. (ada_language_defn): Remove entries for la_builtin_type_vector and string_char_type and use ada_language_arch_info. (_initialize_ada_language): Do type-vector initialization along the lines of c-lang.c. (ada_create_fundamental_type): Break up line. (ada_dump_symtab): Remove unused function. (enum ada_primitive_types): Define. * ada-lang.h (builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long,builtin_type_ada_long_long,builtin_type_ada_char, builtin_type_ada_float, builtin_type_ada_double, builtin_type_ada_long_double, builtin_type_ada_natural, builtin_type_ada_positive, builtin_type_ada_system_address): Remove. * ada-lex.l: Use type_* functions in place of builtin_* variables. (processInt): Ditto. (processReal): Ditto. (name_lookup): Ditto. * ada-typeprint.c (print_range): Use builtin_type_int, not builtin_type_ada_int.
2004-09-19 00:23:23 +02:00
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
static struct type *type_boolean (struct parser_state *);
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
static struct type *type_system_address (struct parser_state *);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
%}
2002-06-04 17:28:49 +02:00
%union
{
LONGEST lval;
struct {
LONGEST val;
struct type *type;
} typed_val;
struct {
Target FP: Use target format throughout expression parsing When parsing floating-point literals, the language parsers currently use parse_float or some equivalent routine to parse the input string into a DOUBLEST, which is then stored within a OP_DOUBLE expression node. When evaluating the expression, the OP_DOUBLE is finally converted into a value in target format. On the other hand, *decimal* floating-point literals are parsed directly into target format and stored that way in a OP_DECFLOAT expression node. In order to eliminate the DOUBLEST, this patch therefore unifies the handling of binary and decimal floating- point literals and stores them both in target format within a new OP_FLOAT expression node, replacing both OP_DOUBLE and OP_DECFLOAT. In order to store literals in target format, the parse_float routine needs to know the type of the literal. All parsers therefore need to be changed to determine the appropriate type (e.g. by detecting suffixes) *before* calling parse_float, instead of after it as today. However, this change is mostly straightforward -- again, this is already done for decimal FP today. The core of the literal parsing is moved into a new routine floatformat_from_string, mirroring floatformat_to_string. The parse_float routine now calls either floatformat_from_string or decimal_from_sting, allowing it to handle any type of FP literal. All language parsers need to be updated. Some notes on specific changes to the various languages: - C: Decimal FP is now handled in parse_float, and no longer needs to be handled specially. - D: Straightforward. - Fortran: Still used a hard-coded "atof", also replaced by parse_float now. Continues to always use builtin_real_s8 as the type of literal, even though this is probably wrong. - Go: This used to handle "f" and "l" suffixes, even though the Go language actually doesn't support those. I kept this support for now -- maybe revisit later. Note the the GDB test suite for some reason actually *verifies* that GDB supports those unsupported suffixes ... - Pascal: Likewise -- this handles suffixes that are not supported in the language standard. - Modula-2: Like Fortran, used to use "atof". - Rust: Mostly straightforward, except for a unit-testing hitch. The code use to set a special "unit_testing" flag which would cause "rust_type" to always return NULL. This makes it not possible to encode a literal into target format (which type?). The reason for this flag appears to have been that during unit testing, there is no "rust_parser" context set up, which means no "gdbarch" is available to use its types. To fix this, I removed the unit_testing flag, and instead simply just set up a dummy rust_parser context during unit testing. - Ada: This used to check sizeof (DOUBLEST) to determine which type to use for floating-point literal. This seems questionable to begin with (since DOUBLEST is quite unrelated to target formats), and in any case we need to get rid of DOUBLEST. I'm now simply always using the largest type (builtin_long_double). gdb/ChangeLog: 2017-10-25 Ulrich Weigand <uweigand@de.ibm.com> * doublest.c (floatformat_from_string): New function. * doublest.h (floatformat_from_string): Add prototype. * std-operator.def (OP_DOUBLE, OP_DECFLOAT): Remove, replace by ... (OP_FLOAT): ... this. * expression.h: Do not include "doublest.h". (union exp_element): Replace doubleconst and decfloatconst by new element floatconst. * ada-lang.c (resolve_subexp): Handle OP_FLOAT instead of OP_DOUBLE. (ada_evaluate_subexp): Likewise. * eval.c (evaluate_subexp_standard): Handle OP_FLOAT instead of OP_DOUBLE and OP_DECFLOAT. * expprint.c (print_subexp_standard): Likewise. (dump_subexp_body_standard): Likewise. * breakpoint.c (watchpoint_exp_is_const): Likewise. * parse.c: Include "dfp.h". (write_exp_elt_dblcst, write_exp_elt_decfloatcst): Remove. (write_exp_elt_floatcst): New function. (operator_length_standard): Handle OP_FLOAT instead of OP_DOUBLE and OP_DECFLOAT. (operator_check_standard): Likewise. (parse_float): Do not accept suffix. Take type as input. Return bool. Return target format buffer instead of host DOUBLEST. Use floatformat_from_string and decimal_from_string to parse either binary or decimal floating-point types. (parse_c_float): Remove. * parser-defs.h: Do not include "doublest.h". (write_exp_elt_dblcst, write_exp_elt_decfloatcst): Remove. (write_exp_elt_floatcst): Add prototype. (parse_float): Update prototype. (parse_c_float): Remove. * c-exp.y: Do not include "dfp.h". (typed_val_float): Use byte buffer instead of DOUBLEST. (typed_val_decfloat): Remove. (DECFLOAT): Remove. (FLOAT): Use OP_FLOAT and write_exp_elt_floatcst. (parse_number): Update to new parse_float interface. Parse suffixes and determine type before calling parse_float. Handle decimal and binary FP types the same way. * d-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST. (FLOAT_LITERAL): Use OP_FLOAT and write_exp_elt_floatcst. (parse_number): Update to new parse_float interface. Parse suffixes and determine type before calling parse_float. * f-exp.y: Replace dval by typed_val_float. (FLOAT): Use OP_FLOAT and write_exp_elt_floatcst. (parse_number): Use parse_float instead of atof. * go-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST. (parse_go_float): Remove. (FLOAT): Use OP_FLOAT and write_exp_elt_floatcst. (parse_number): Call parse_float instead of parse_go_float. Parse suffixes and determine type before calling parse_float. * p-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST. (FLOAT): Use OP_FLOAT and write_exp_elt_floatcst. (parse_number): Update to new parse_float interface. Parse suffixes and determine type before calling parse_float. * m2-exp.y: Replace dval by byte buffer val. (FLOAT): Use OP_FLOAT and write_exp_elt_floatcst. (parse_number): Call parse_float instead of atof. * rust-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST. (lex_number): Call parse_float instead of strtod. (ast_dliteral): Use OP_FLOAT instead of OP_DOUBLE. (convert_ast_to_expression): Handle OP_FLOAT instead of OP_DOUBLE. Use write_exp_elt_floatcst. (unit_testing): Remove static variable. (rust_type): Do not check unit_testing. (rust_lex_tests): Do not set uint_testing. Set up dummy rust_parser. * ada-exp.y (type_float, type_double): Remove. (typed_val_float): Use byte buffer instead of DOUBLEST. (FLOAT): Use OP_FLOAT and write_exp_elt_floatcst. * ada-lex.l (processReal): Use parse_float instead of sscanf.
2017-10-25 15:32:23 +02:00
gdb_byte val[16];
2002-06-04 17:28:49 +02:00
struct type *type;
} typed_val_float;
struct type *tval;
struct stoken sval;
constify struct block in some places This makes some spots in gdb, particularly general_symbol_info, use a "const struct block", then fixes the fallout. The justification is that, ordinarily, blocks ought to be readonly. Note though that we can't add "const" in the blockvector due to block relocation. This can be done once blocks are made independent of the program space. 2014-06-18 Tom Tromey <tromey@redhat.com> * varobj.c (varobj_create): Update. * valops.c (value_of_this): Update. * tracepoint.c (add_local_symbols, scope_info): Update. * symtab.h (struct general_symbol_info) <block>: Now const. * symtab.c (skip_prologue_sal) (default_make_symbol_completion_list_break_on) (skip_prologue_using_sal): Update. * stack.h (iterate_over_block_locals) (iterate_over_block_local_vars): Update. * stack.c (print_frame_args): Update. (iterate_over_block_locals, iterate_over_block_local_vars): Make parameter const. (get_selected_block): Make return type const. * python/py-frame.c (frapy_block): Update. * python/py-block.c (gdbpy_block_for_pc): Update. * p-exp.y (%union) <bval>: Now const. * mi/mi-cmd-stack.c (list_args_or_locals): Update. * mdebugread.c (mylookup_symbol, parse_procedure): Update. * m2-exp.y (%union) <bval>: Now const. * linespec.c (get_current_search_block): Make return type const. (create_sals_line_offset, find_label_symbols): Update. * inline-frame.c (inline_frame_sniffer, skip_inline_frames): Update. (block_starting_point_at): Make "block" const. * infrun.c (insert_exception_resume_breakpoint): Make "b" const. (check_exception_resume): Update. * guile/scm-frame.c (gdbscm_frame_block): Update. * guile/scm-block.c (gdbscm_lookup_block): Update. * frame.h (get_frame_block): Update. (get_selected_block): Make return type const. * frame.c (frame_id_inner): Update. * f-valprint.c (info_common_command_for_block) (info_common_command): Update. * dwarf2loc.c (dwarf2_find_location_expression) (dwarf_expr_frame_base, dwarf2_compile_expr_to_ax) (locexpr_describe_location_piece): Update. * c-exp.y (%union) <bval>: Now const. * breakpoint.c (resolve_sal_pc): Update. * blockframe.c (get_frame_block):Make return type const. (get_pc_function_start, get_frame_function, find_pc_sect_function) (block_innermost_frame): Update. * block.h (blockvector_for_pc, blockvector_for_pc_sect) (block_for_pc, block_for_pc_sect): Update. * block.c (blockvector_for_pc_sect, blockvector_for_pc): Make 'pblock' const. (block_for_pc_sect, block_for_pc): Make return type const. * ax-gdb.c (gen_expr): Update. * alpha-mdebug-tdep.c (find_proc_desc): Update. * ada-lang.c (ada_read_renaming_var_value): Make 'block' const. (ada_make_symbol_completion_list, ada_add_exceptions_from_frame) (ada_read_var_value): Update. * ada-exp.y (struct name_info) <block>: Now const. (%union): Likewise. (block_lookup): Constify.
2013-03-12 16:51:37 +01:00
const struct block *bval;
2002-06-04 17:28:49 +02:00
struct internalvar *ivar;
}
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
%type <lval> positional_list component_groups component_associations
%type <lval> aggregate_component_list
%type <tval> var_or_type
2002-06-04 17:28:49 +02:00
%token <typed_val> INT NULL_PTR CHARLIT
%token <typed_val_float> FLOAT
%token TRUEKEYWORD FALSEKEYWORD
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
%token COLONCOLON
%token <sval> STRING NAME DOT_ID
%type <bval> block
2002-06-04 17:28:49 +02:00
%type <lval> arglist tick_arglist
%type <tval> save_qualifier
%token DOT_ALL
/* Special type cases, put in to allow the parser to distinguish different
legal basetypes. */
%token <sval> DOLLAR_VARIABLE
2002-06-04 17:28:49 +02:00
%nonassoc ASSIGN
%left _AND_ OR XOR THEN ELSE
%left '=' NOTEQUAL '<' '>' LEQ GEQ IN DOTDOT
%left '@'
%left '+' '-' '&'
%left UNARY
%left '*' '/' MOD REM
%right STARSTAR ABS NOT
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
/* Artificial token to give NAME => ... and NAME | priority over reducing
NAME to <primary> and to give <primary>' priority over reducing <primary>
to <simple_exp>. */
%nonassoc VAR
%nonassoc ARROW '|'
2002-06-04 17:28:49 +02:00
%right TICK_ACCESS TICK_ADDRESS TICK_FIRST TICK_LAST TICK_LENGTH
%right TICK_MAX TICK_MIN TICK_MODULUS
%right TICK_POS TICK_RANGE TICK_SIZE TICK_TAG TICK_VAL
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
/* The following are right-associative only so that reductions at this
precedence have lower precedence than '.' and '('. The syntax still
forces a.b.c, e.g., to be LEFT-associated. */
2002-06-04 17:28:49 +02:00
%right '.' '(' '[' DOT_ID DOT_ALL
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
%token NEW OTHERS
2002-06-04 17:28:49 +02:00
%%
start : exp1
;
/* Expressions, including the sequencing operator. */
exp1 : exp
| exp1 ';' exp
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, BINOP_COMMA); }
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
| primary ASSIGN exp /* Extension for convenience */
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, BINOP_ASSIGN); }
2002-06-04 17:28:49 +02:00
;
/* Expressions, not including the sequencing operator. */
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
primary : primary DOT_ALL
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, UNOP_IND); }
2002-06-04 17:28:49 +02:00
;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
primary : primary DOT_ID
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_op_with_string (pstate, STRUCTOP_STRUCT,
$2); }
2002-06-04 17:28:49 +02:00
;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
primary : primary '(' arglist ')'
2002-06-04 17:28:49 +02:00
{
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_exp_elt_opcode (pstate, OP_FUNCALL);
write_exp_elt_longcst (pstate, $3);
write_exp_elt_opcode (pstate, OP_FUNCALL);
2002-06-04 17:28:49 +02:00
}
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
| var_or_type '(' arglist ')'
2002-06-04 17:28:49 +02:00
{
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
if ($1 != NULL)
{
if ($3 != 1)
error (_("Invalid conversion"));
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_exp_elt_opcode (pstate, UNOP_CAST);
write_exp_elt_type (pstate, $1);
write_exp_elt_opcode (pstate, UNOP_CAST);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
}
else
{
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_exp_elt_opcode (pstate, OP_FUNCALL);
write_exp_elt_longcst (pstate, $3);
write_exp_elt_opcode (pstate, OP_FUNCALL);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
}
2002-06-04 17:28:49 +02:00
}
;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
primary : var_or_type '\'' save_qualifier { type_qualifier = $1; }
'(' exp ')'
2002-06-04 17:28:49 +02:00
{
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
if ($1 == NULL)
error (_("Type required for qualification"));
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_exp_elt_opcode (pstate, UNOP_QUAL);
write_exp_elt_type (pstate, $1);
write_exp_elt_opcode (pstate, UNOP_QUAL);
2002-06-04 17:28:49 +02:00
type_qualifier = $3;
}
;
save_qualifier : { $$ = type_qualifier; }
;
2002-06-04 17:28:49 +02:00
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
primary :
primary '(' simple_exp DOTDOT simple_exp ')'
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, TERNOP_SLICE); }
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
| var_or_type '(' simple_exp DOTDOT simple_exp ')'
{ if ($1 == NULL)
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_exp_elt_opcode (pstate, TERNOP_SLICE);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
else
error (_("Cannot slice a type"));
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
}
2002-06-04 17:28:49 +02:00
;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
primary : '(' exp1 ')' { }
2002-06-04 17:28:49 +02:00
;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
/* The following rule causes a conflict with the type conversion
var_or_type (exp)
To get around it, we give '(' higher priority and add bridge rules for
var_or_type (exp, exp, ...)
var_or_type (exp .. exp)
We also have the action for var_or_type(exp) generate a function call
when the first symbol does not denote a type. */
primary : var_or_type %prec VAR
{ if ($1 != NULL)
{
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_exp_elt_opcode (pstate, OP_TYPE);
write_exp_elt_type (pstate, $1);
write_exp_elt_opcode (pstate, OP_TYPE);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
}
}
2002-06-04 17:28:49 +02:00
;
primary : DOLLAR_VARIABLE /* Various GDB extensions */
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_dollar_variable (pstate, $1); }
2002-06-04 17:28:49 +02:00
;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
primary : aggregate
;
2002-06-04 17:28:49 +02:00
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
simple_exp : primary
2002-06-04 17:28:49 +02:00
;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
simple_exp : '-' simple_exp %prec UNARY
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, UNOP_NEG); }
2002-06-04 17:28:49 +02:00
;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
simple_exp : '+' simple_exp %prec UNARY
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, UNOP_PLUS); }
2002-06-04 17:28:49 +02:00
;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
simple_exp : NOT simple_exp %prec UNARY
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, UNOP_LOGICAL_NOT); }
2002-06-04 17:28:49 +02:00
;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
simple_exp : ABS simple_exp %prec UNARY
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, UNOP_ABS); }
2002-06-04 17:28:49 +02:00
;
arglist : { $$ = 0; }
;
arglist : exp
{ $$ = 1; }
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
| NAME ARROW exp
2002-06-04 17:28:49 +02:00
{ $$ = 1; }
| arglist ',' exp
{ $$ = $1 + 1; }
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
| arglist ',' NAME ARROW exp
2002-06-04 17:28:49 +02:00
{ $$ = $1 + 1; }
;
primary : '{' var_or_type '}' primary %prec '.'
2002-06-04 17:28:49 +02:00
/* GDB extension */
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
{
if ($2 == NULL)
error (_("Type required within braces in coercion"));
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_exp_elt_opcode (pstate, UNOP_MEMVAL);
write_exp_elt_type (pstate, $2);
write_exp_elt_opcode (pstate, UNOP_MEMVAL);
2002-06-04 17:28:49 +02:00
}
;
/* Binary operators in order of decreasing precedence. */
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
simple_exp : simple_exp STARSTAR simple_exp
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, BINOP_EXP); }
2002-06-04 17:28:49 +02:00
;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
simple_exp : simple_exp '*' simple_exp
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, BINOP_MUL); }
2002-06-04 17:28:49 +02:00
;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
simple_exp : simple_exp '/' simple_exp
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, BINOP_DIV); }
2002-06-04 17:28:49 +02:00
;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
simple_exp : simple_exp REM simple_exp /* May need to be fixed to give correct Ada REM */
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, BINOP_REM); }
2002-06-04 17:28:49 +02:00
;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
simple_exp : simple_exp MOD simple_exp
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, BINOP_MOD); }
2002-06-04 17:28:49 +02:00
;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
simple_exp : simple_exp '@' simple_exp /* GDB extension */
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, BINOP_REPEAT); }
2002-06-04 17:28:49 +02:00
;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
simple_exp : simple_exp '+' simple_exp
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, BINOP_ADD); }
2002-06-04 17:28:49 +02:00
;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
simple_exp : simple_exp '&' simple_exp
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, BINOP_CONCAT); }
2002-06-04 17:28:49 +02:00
;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
simple_exp : simple_exp '-' simple_exp
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, BINOP_SUB); }
2002-06-04 17:28:49 +02:00
;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
relation : simple_exp
;
relation : simple_exp '=' simple_exp
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, BINOP_EQUAL); }
2002-06-04 17:28:49 +02:00
;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
relation : simple_exp NOTEQUAL simple_exp
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, BINOP_NOTEQUAL); }
2002-06-04 17:28:49 +02:00
;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
relation : simple_exp LEQ simple_exp
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, BINOP_LEQ); }
2002-06-04 17:28:49 +02:00
;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
relation : simple_exp IN simple_exp DOTDOT simple_exp
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, TERNOP_IN_RANGE); }
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
| simple_exp IN primary TICK_RANGE tick_arglist
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, BINOP_IN_BOUNDS);
write_exp_elt_longcst (pstate, (LONGEST) $5);
write_exp_elt_opcode (pstate, BINOP_IN_BOUNDS);
2002-06-04 17:28:49 +02:00
}
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
| simple_exp IN var_or_type %prec TICK_ACCESS
{
if ($3 == NULL)
error (_("Right operand of 'in' must be type"));
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_exp_elt_opcode (pstate, UNOP_IN_RANGE);
write_exp_elt_type (pstate, $3);
write_exp_elt_opcode (pstate, UNOP_IN_RANGE);
2002-06-04 17:28:49 +02:00
}
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
| simple_exp NOT IN simple_exp DOTDOT simple_exp
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, TERNOP_IN_RANGE);
write_exp_elt_opcode (pstate, UNOP_LOGICAL_NOT);
2002-06-04 17:28:49 +02:00
}
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
| simple_exp NOT IN primary TICK_RANGE tick_arglist
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, BINOP_IN_BOUNDS);
write_exp_elt_longcst (pstate, (LONGEST) $6);
write_exp_elt_opcode (pstate, BINOP_IN_BOUNDS);
write_exp_elt_opcode (pstate, UNOP_LOGICAL_NOT);
2002-06-04 17:28:49 +02:00
}
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
| simple_exp NOT IN var_or_type %prec TICK_ACCESS
{
if ($4 == NULL)
error (_("Right operand of 'in' must be type"));
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_exp_elt_opcode (pstate, UNOP_IN_RANGE);
write_exp_elt_type (pstate, $4);
write_exp_elt_opcode (pstate, UNOP_IN_RANGE);
write_exp_elt_opcode (pstate, UNOP_LOGICAL_NOT);
2002-06-04 17:28:49 +02:00
}
;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
relation : simple_exp GEQ simple_exp
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, BINOP_GEQ); }
2002-06-04 17:28:49 +02:00
;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
relation : simple_exp '<' simple_exp
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, BINOP_LESS); }
2002-06-04 17:28:49 +02:00
;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
relation : simple_exp '>' simple_exp
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, BINOP_GTR); }
2002-06-04 17:28:49 +02:00
;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
exp : relation
| and_exp
| and_then_exp
| or_exp
| or_else_exp
| xor_exp
;
and_exp :
relation _AND_ relation
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, BINOP_BITWISE_AND); }
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
| and_exp _AND_ relation
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, BINOP_BITWISE_AND); }
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
;
2002-06-04 17:28:49 +02:00
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
and_then_exp :
relation _AND_ THEN relation
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, BINOP_LOGICAL_AND); }
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
| and_then_exp _AND_ THEN relation
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, BINOP_LOGICAL_AND); }
2002-06-04 17:28:49 +02:00
;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
or_exp :
relation OR relation
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, BINOP_BITWISE_IOR); }
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
| or_exp OR relation
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, BINOP_BITWISE_IOR); }
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
;
2002-06-04 17:28:49 +02:00
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
or_else_exp :
relation OR ELSE relation
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, BINOP_LOGICAL_OR); }
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
| or_else_exp OR ELSE relation
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, BINOP_LOGICAL_OR); }
2002-06-04 17:28:49 +02:00
;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
xor_exp : relation XOR relation
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, BINOP_BITWISE_XOR); }
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
| xor_exp XOR relation
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, BINOP_BITWISE_XOR); }
2002-06-04 17:28:49 +02:00
;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
/* Primaries can denote types (OP_TYPE). In cases such as
primary TICK_ADDRESS, where a type would be invalid, it will be
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
caught when evaluate_subexp in ada-lang.c tries to evaluate the
primary, expecting a value. Precedence rules resolve the ambiguity
in NAME TICK_ACCESS in favor of shifting to form a var_or_type. A
construct such as aType'access'access will again cause an error when
aType'access evaluates to a type that evaluate_subexp attempts to
evaluate. */
primary : primary TICK_ACCESS
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, UNOP_ADDR); }
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
| primary TICK_ADDRESS
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, UNOP_ADDR);
write_exp_elt_opcode (pstate, UNOP_CAST);
write_exp_elt_type (pstate,
type_system_address (pstate));
write_exp_elt_opcode (pstate, UNOP_CAST);
2002-06-04 17:28:49 +02:00
}
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
| primary TICK_FIRST tick_arglist
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_int (pstate, $3, type_int (pstate));
write_exp_elt_opcode (pstate, OP_ATR_FIRST); }
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
| primary TICK_LAST tick_arglist
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_int (pstate, $3, type_int (pstate));
write_exp_elt_opcode (pstate, OP_ATR_LAST); }
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
| primary TICK_LENGTH tick_arglist
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_int (pstate, $3, type_int (pstate));
write_exp_elt_opcode (pstate, OP_ATR_LENGTH); }
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
| primary TICK_SIZE
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, OP_ATR_SIZE); }
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
| primary TICK_TAG
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, OP_ATR_TAG); }
2002-06-04 17:28:49 +02:00
| opt_type_prefix TICK_MIN '(' exp ',' exp ')'
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, OP_ATR_MIN); }
2002-06-04 17:28:49 +02:00
| opt_type_prefix TICK_MAX '(' exp ',' exp ')'
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, OP_ATR_MAX); }
2002-06-04 17:28:49 +02:00
| opt_type_prefix TICK_POS '(' exp ')'
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, OP_ATR_POS); }
2002-06-04 17:28:49 +02:00
| type_prefix TICK_VAL '(' exp ')'
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, OP_ATR_VAL); }
| type_prefix TICK_MODULUS
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, OP_ATR_MODULUS); }
2002-06-04 17:28:49 +02:00
;
tick_arglist : %prec '('
{ $$ = 1; }
| '(' INT ')'
{ $$ = $2.val; }
;
type_prefix :
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
var_or_type
{
if ($1 == NULL)
error (_("Prefix must be type"));
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_exp_elt_opcode (pstate, OP_TYPE);
write_exp_elt_type (pstate, $1);
write_exp_elt_opcode (pstate, OP_TYPE); }
2002-06-04 17:28:49 +02:00
;
opt_type_prefix :
type_prefix
| /* EMPTY */
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, OP_TYPE);
write_exp_elt_type (pstate,
parse_type (pstate)->builtin_void);
write_exp_elt_opcode (pstate, OP_TYPE); }
2002-06-04 17:28:49 +02:00
;
2002-06-04 17:28:49 +02:00
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
primary : INT
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_int (pstate, (LONGEST) $1.val, $1.type); }
2002-06-04 17:28:49 +02:00
;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
primary : CHARLIT
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_int (pstate,
convert_char_literal (type_qualifier, $1.val),
(type_qualifier == NULL)
? $1.type : type_qualifier);
}
;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
primary : FLOAT
Target FP: Use target format throughout expression parsing When parsing floating-point literals, the language parsers currently use parse_float or some equivalent routine to parse the input string into a DOUBLEST, which is then stored within a OP_DOUBLE expression node. When evaluating the expression, the OP_DOUBLE is finally converted into a value in target format. On the other hand, *decimal* floating-point literals are parsed directly into target format and stored that way in a OP_DECFLOAT expression node. In order to eliminate the DOUBLEST, this patch therefore unifies the handling of binary and decimal floating- point literals and stores them both in target format within a new OP_FLOAT expression node, replacing both OP_DOUBLE and OP_DECFLOAT. In order to store literals in target format, the parse_float routine needs to know the type of the literal. All parsers therefore need to be changed to determine the appropriate type (e.g. by detecting suffixes) *before* calling parse_float, instead of after it as today. However, this change is mostly straightforward -- again, this is already done for decimal FP today. The core of the literal parsing is moved into a new routine floatformat_from_string, mirroring floatformat_to_string. The parse_float routine now calls either floatformat_from_string or decimal_from_sting, allowing it to handle any type of FP literal. All language parsers need to be updated. Some notes on specific changes to the various languages: - C: Decimal FP is now handled in parse_float, and no longer needs to be handled specially. - D: Straightforward. - Fortran: Still used a hard-coded "atof", also replaced by parse_float now. Continues to always use builtin_real_s8 as the type of literal, even though this is probably wrong. - Go: This used to handle "f" and "l" suffixes, even though the Go language actually doesn't support those. I kept this support for now -- maybe revisit later. Note the the GDB test suite for some reason actually *verifies* that GDB supports those unsupported suffixes ... - Pascal: Likewise -- this handles suffixes that are not supported in the language standard. - Modula-2: Like Fortran, used to use "atof". - Rust: Mostly straightforward, except for a unit-testing hitch. The code use to set a special "unit_testing" flag which would cause "rust_type" to always return NULL. This makes it not possible to encode a literal into target format (which type?). The reason for this flag appears to have been that during unit testing, there is no "rust_parser" context set up, which means no "gdbarch" is available to use its types. To fix this, I removed the unit_testing flag, and instead simply just set up a dummy rust_parser context during unit testing. - Ada: This used to check sizeof (DOUBLEST) to determine which type to use for floating-point literal. This seems questionable to begin with (since DOUBLEST is quite unrelated to target formats), and in any case we need to get rid of DOUBLEST. I'm now simply always using the largest type (builtin_long_double). gdb/ChangeLog: 2017-10-25 Ulrich Weigand <uweigand@de.ibm.com> * doublest.c (floatformat_from_string): New function. * doublest.h (floatformat_from_string): Add prototype. * std-operator.def (OP_DOUBLE, OP_DECFLOAT): Remove, replace by ... (OP_FLOAT): ... this. * expression.h: Do not include "doublest.h". (union exp_element): Replace doubleconst and decfloatconst by new element floatconst. * ada-lang.c (resolve_subexp): Handle OP_FLOAT instead of OP_DOUBLE. (ada_evaluate_subexp): Likewise. * eval.c (evaluate_subexp_standard): Handle OP_FLOAT instead of OP_DOUBLE and OP_DECFLOAT. * expprint.c (print_subexp_standard): Likewise. (dump_subexp_body_standard): Likewise. * breakpoint.c (watchpoint_exp_is_const): Likewise. * parse.c: Include "dfp.h". (write_exp_elt_dblcst, write_exp_elt_decfloatcst): Remove. (write_exp_elt_floatcst): New function. (operator_length_standard): Handle OP_FLOAT instead of OP_DOUBLE and OP_DECFLOAT. (operator_check_standard): Likewise. (parse_float): Do not accept suffix. Take type as input. Return bool. Return target format buffer instead of host DOUBLEST. Use floatformat_from_string and decimal_from_string to parse either binary or decimal floating-point types. (parse_c_float): Remove. * parser-defs.h: Do not include "doublest.h". (write_exp_elt_dblcst, write_exp_elt_decfloatcst): Remove. (write_exp_elt_floatcst): Add prototype. (parse_float): Update prototype. (parse_c_float): Remove. * c-exp.y: Do not include "dfp.h". (typed_val_float): Use byte buffer instead of DOUBLEST. (typed_val_decfloat): Remove. (DECFLOAT): Remove. (FLOAT): Use OP_FLOAT and write_exp_elt_floatcst. (parse_number): Update to new parse_float interface. Parse suffixes and determine type before calling parse_float. Handle decimal and binary FP types the same way. * d-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST. (FLOAT_LITERAL): Use OP_FLOAT and write_exp_elt_floatcst. (parse_number): Update to new parse_float interface. Parse suffixes and determine type before calling parse_float. * f-exp.y: Replace dval by typed_val_float. (FLOAT): Use OP_FLOAT and write_exp_elt_floatcst. (parse_number): Use parse_float instead of atof. * go-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST. (parse_go_float): Remove. (FLOAT): Use OP_FLOAT and write_exp_elt_floatcst. (parse_number): Call parse_float instead of parse_go_float. Parse suffixes and determine type before calling parse_float. * p-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST. (FLOAT): Use OP_FLOAT and write_exp_elt_floatcst. (parse_number): Update to new parse_float interface. Parse suffixes and determine type before calling parse_float. * m2-exp.y: Replace dval by byte buffer val. (FLOAT): Use OP_FLOAT and write_exp_elt_floatcst. (parse_number): Call parse_float instead of atof. * rust-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST. (lex_number): Call parse_float instead of strtod. (ast_dliteral): Use OP_FLOAT instead of OP_DOUBLE. (convert_ast_to_expression): Handle OP_FLOAT instead of OP_DOUBLE. Use write_exp_elt_floatcst. (unit_testing): Remove static variable. (rust_type): Do not check unit_testing. (rust_lex_tests): Do not set uint_testing. Set up dummy rust_parser. * ada-exp.y (type_float, type_double): Remove. (typed_val_float): Use byte buffer instead of DOUBLEST. (FLOAT): Use OP_FLOAT and write_exp_elt_floatcst. * ada-lex.l (processReal): Use parse_float instead of sscanf.
2017-10-25 15:32:23 +02:00
{ write_exp_elt_opcode (pstate, OP_FLOAT);
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_exp_elt_type (pstate, $1.type);
Target FP: Use target format throughout expression parsing When parsing floating-point literals, the language parsers currently use parse_float or some equivalent routine to parse the input string into a DOUBLEST, which is then stored within a OP_DOUBLE expression node. When evaluating the expression, the OP_DOUBLE is finally converted into a value in target format. On the other hand, *decimal* floating-point literals are parsed directly into target format and stored that way in a OP_DECFLOAT expression node. In order to eliminate the DOUBLEST, this patch therefore unifies the handling of binary and decimal floating- point literals and stores them both in target format within a new OP_FLOAT expression node, replacing both OP_DOUBLE and OP_DECFLOAT. In order to store literals in target format, the parse_float routine needs to know the type of the literal. All parsers therefore need to be changed to determine the appropriate type (e.g. by detecting suffixes) *before* calling parse_float, instead of after it as today. However, this change is mostly straightforward -- again, this is already done for decimal FP today. The core of the literal parsing is moved into a new routine floatformat_from_string, mirroring floatformat_to_string. The parse_float routine now calls either floatformat_from_string or decimal_from_sting, allowing it to handle any type of FP literal. All language parsers need to be updated. Some notes on specific changes to the various languages: - C: Decimal FP is now handled in parse_float, and no longer needs to be handled specially. - D: Straightforward. - Fortran: Still used a hard-coded "atof", also replaced by parse_float now. Continues to always use builtin_real_s8 as the type of literal, even though this is probably wrong. - Go: This used to handle "f" and "l" suffixes, even though the Go language actually doesn't support those. I kept this support for now -- maybe revisit later. Note the the GDB test suite for some reason actually *verifies* that GDB supports those unsupported suffixes ... - Pascal: Likewise -- this handles suffixes that are not supported in the language standard. - Modula-2: Like Fortran, used to use "atof". - Rust: Mostly straightforward, except for a unit-testing hitch. The code use to set a special "unit_testing" flag which would cause "rust_type" to always return NULL. This makes it not possible to encode a literal into target format (which type?). The reason for this flag appears to have been that during unit testing, there is no "rust_parser" context set up, which means no "gdbarch" is available to use its types. To fix this, I removed the unit_testing flag, and instead simply just set up a dummy rust_parser context during unit testing. - Ada: This used to check sizeof (DOUBLEST) to determine which type to use for floating-point literal. This seems questionable to begin with (since DOUBLEST is quite unrelated to target formats), and in any case we need to get rid of DOUBLEST. I'm now simply always using the largest type (builtin_long_double). gdb/ChangeLog: 2017-10-25 Ulrich Weigand <uweigand@de.ibm.com> * doublest.c (floatformat_from_string): New function. * doublest.h (floatformat_from_string): Add prototype. * std-operator.def (OP_DOUBLE, OP_DECFLOAT): Remove, replace by ... (OP_FLOAT): ... this. * expression.h: Do not include "doublest.h". (union exp_element): Replace doubleconst and decfloatconst by new element floatconst. * ada-lang.c (resolve_subexp): Handle OP_FLOAT instead of OP_DOUBLE. (ada_evaluate_subexp): Likewise. * eval.c (evaluate_subexp_standard): Handle OP_FLOAT instead of OP_DOUBLE and OP_DECFLOAT. * expprint.c (print_subexp_standard): Likewise. (dump_subexp_body_standard): Likewise. * breakpoint.c (watchpoint_exp_is_const): Likewise. * parse.c: Include "dfp.h". (write_exp_elt_dblcst, write_exp_elt_decfloatcst): Remove. (write_exp_elt_floatcst): New function. (operator_length_standard): Handle OP_FLOAT instead of OP_DOUBLE and OP_DECFLOAT. (operator_check_standard): Likewise. (parse_float): Do not accept suffix. Take type as input. Return bool. Return target format buffer instead of host DOUBLEST. Use floatformat_from_string and decimal_from_string to parse either binary or decimal floating-point types. (parse_c_float): Remove. * parser-defs.h: Do not include "doublest.h". (write_exp_elt_dblcst, write_exp_elt_decfloatcst): Remove. (write_exp_elt_floatcst): Add prototype. (parse_float): Update prototype. (parse_c_float): Remove. * c-exp.y: Do not include "dfp.h". (typed_val_float): Use byte buffer instead of DOUBLEST. (typed_val_decfloat): Remove. (DECFLOAT): Remove. (FLOAT): Use OP_FLOAT and write_exp_elt_floatcst. (parse_number): Update to new parse_float interface. Parse suffixes and determine type before calling parse_float. Handle decimal and binary FP types the same way. * d-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST. (FLOAT_LITERAL): Use OP_FLOAT and write_exp_elt_floatcst. (parse_number): Update to new parse_float interface. Parse suffixes and determine type before calling parse_float. * f-exp.y: Replace dval by typed_val_float. (FLOAT): Use OP_FLOAT and write_exp_elt_floatcst. (parse_number): Use parse_float instead of atof. * go-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST. (parse_go_float): Remove. (FLOAT): Use OP_FLOAT and write_exp_elt_floatcst. (parse_number): Call parse_float instead of parse_go_float. Parse suffixes and determine type before calling parse_float. * p-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST. (FLOAT): Use OP_FLOAT and write_exp_elt_floatcst. (parse_number): Update to new parse_float interface. Parse suffixes and determine type before calling parse_float. * m2-exp.y: Replace dval by byte buffer val. (FLOAT): Use OP_FLOAT and write_exp_elt_floatcst. (parse_number): Call parse_float instead of atof. * rust-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST. (lex_number): Call parse_float instead of strtod. (ast_dliteral): Use OP_FLOAT instead of OP_DOUBLE. (convert_ast_to_expression): Handle OP_FLOAT instead of OP_DOUBLE. Use write_exp_elt_floatcst. (unit_testing): Remove static variable. (rust_type): Do not check unit_testing. (rust_lex_tests): Do not set uint_testing. Set up dummy rust_parser. * ada-exp.y (type_float, type_double): Remove. (typed_val_float): Use byte buffer instead of DOUBLEST. (FLOAT): Use OP_FLOAT and write_exp_elt_floatcst. * ada-lex.l (processReal): Use parse_float instead of sscanf.
2017-10-25 15:32:23 +02:00
write_exp_elt_floatcst (pstate, $1.val);
write_exp_elt_opcode (pstate, OP_FLOAT);
2002-06-04 17:28:49 +02:00
}
;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
primary : NULL_PTR
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_int (pstate, 0, type_int (pstate)); }
;
2002-06-04 17:28:49 +02:00
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
primary : STRING
{
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_exp_op_with_string (pstate, OP_STRING, $1);
}
2002-06-04 17:28:49 +02:00
;
primary : TRUEKEYWORD
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_int (pstate, 1, type_boolean (pstate)); }
| FALSEKEYWORD
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_int (pstate, 0, type_boolean (pstate)); }
;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
primary : NEW NAME
{ error (_("NEW not implemented.")); }
2002-06-04 17:28:49 +02:00
;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
var_or_type: NAME %prec VAR
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ $$ = write_var_or_type (pstate, NULL, $1); }
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
| block NAME %prec VAR
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ $$ = write_var_or_type (pstate, $1, $2); }
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
| NAME TICK_ACCESS
{
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
$$ = write_var_or_type (pstate, NULL, $1);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
if ($$ == NULL)
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_exp_elt_opcode (pstate, UNOP_ADDR);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
else
$$ = lookup_pointer_type ($$);
}
| block NAME TICK_ACCESS
{
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
$$ = write_var_or_type (pstate, $1, $2);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
if ($$ == NULL)
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_exp_elt_opcode (pstate, UNOP_ADDR);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
else
$$ = lookup_pointer_type ($$);
}
2002-06-04 17:28:49 +02:00
;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
/* GDB extension */
block : NAME COLONCOLON
{ $$ = block_lookup (NULL, $1.ptr); }
| block NAME COLONCOLON
{ $$ = block_lookup ($1, $2.ptr); }
;
2002-06-04 17:28:49 +02:00
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
aggregate :
'(' aggregate_component_list ')'
{
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_exp_elt_opcode (pstate, OP_AGGREGATE);
write_exp_elt_longcst (pstate, $2);
write_exp_elt_opcode (pstate, OP_AGGREGATE);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
}
2002-06-04 17:28:49 +02:00
;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
aggregate_component_list :
component_groups { $$ = $1; }
| positional_list exp
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, OP_POSITIONAL);
write_exp_elt_longcst (pstate, $1);
write_exp_elt_opcode (pstate, OP_POSITIONAL);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
$$ = $1 + 1;
}
| positional_list component_groups
{ $$ = $1 + $2; }
;
2002-06-04 17:28:49 +02:00
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
positional_list :
exp ','
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, OP_POSITIONAL);
write_exp_elt_longcst (pstate, 0);
write_exp_elt_opcode (pstate, OP_POSITIONAL);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
$$ = 1;
}
| positional_list exp ','
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, OP_POSITIONAL);
write_exp_elt_longcst (pstate, $1);
write_exp_elt_opcode (pstate, OP_POSITIONAL);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
$$ = $1 + 1;
}
;
component_groups:
others { $$ = 1; }
| component_group { $$ = 1; }
| component_group ',' component_groups
{ $$ = $3 + 1; }
;
others : OTHERS ARROW exp
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, OP_OTHERS); }
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
;
component_group :
component_associations
{
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_exp_elt_opcode (pstate, OP_CHOICES);
write_exp_elt_longcst (pstate, $1);
write_exp_elt_opcode (pstate, OP_CHOICES);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
}
;
/* We use this somewhat obscure definition in order to handle NAME => and
NAME | differently from exp => and exp |. ARROW and '|' have a precedence
above that of the reduction of NAME to var_or_type. By delaying
decisions until after the => or '|', we convert the ambiguity to a
resolved shift/reduce conflict. */
component_associations :
NAME ARROW
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_name_assoc (pstate, $1); }
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
exp { $$ = 1; }
| simple_exp ARROW exp
{ $$ = 1; }
| simple_exp DOTDOT simple_exp ARROW
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, OP_DISCRETE_RANGE);
write_exp_op_with_string (pstate, OP_NAME,
empty_stoken);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
}
exp { $$ = 1; }
| NAME '|'
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_name_assoc (pstate, $1); }
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
component_associations { $$ = $4 + 1; }
| simple_exp '|'
component_associations { $$ = $3 + 1; }
| simple_exp DOTDOT simple_exp '|'
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, OP_DISCRETE_RANGE); }
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
component_associations { $$ = $6 + 1; }
;
2002-06-04 17:28:49 +02:00
/* Some extensions borrowed from C, for the benefit of those who find they
can't get used to Ada notation in GDB. */
2002-06-04 17:28:49 +02:00
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
primary : '*' primary %prec '.'
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, UNOP_IND); }
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
| '&' primary %prec '.'
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, UNOP_ADDR); }
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
| primary '[' exp ']'
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
{ write_exp_elt_opcode (pstate, BINOP_SUBSCRIPT); }
2002-06-04 17:28:49 +02:00
;
%%
/* yylex defined in ada-lex.c: Reads one token, getting characters */
/* through lexptr. */
/* Remap normal flex interface names (yylex) as well as gratuitiously */
/* global symbol names, so we can have multiple flex-generated parsers */
/* in gdb. */
/* (See note above on previous definitions for YACC.) */
#define yy_create_buffer ada_yy_create_buffer
#define yy_delete_buffer ada_yy_delete_buffer
#define yy_init_buffer ada_yy_init_buffer
#define yy_load_buffer_state ada_yy_load_buffer_state
#define yy_switch_to_buffer ada_yy_switch_to_buffer
#define yyrestart ada_yyrestart
#define yytext ada_yytext
static struct obstack temp_parse_space;
2002-06-04 17:28:49 +02:00
/* The following kludge was found necessary to prevent conflicts between */
/* defs.h and non-standard stdlib.h files. */
#define qsort __qsort__dummy
#include "ada-lex.c"
int
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
ada_parse (struct parser_state *par_state)
2002-06-04 17:28:49 +02:00
{
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
/* Setting up the parser state. */
scoped_restore pstate_restore = make_scoped_restore (&pstate);
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
gdb_assert (par_state != NULL);
pstate = par_state;
lexer_init (yyin); /* (Re-)initialize lexer. */
2002-06-04 17:28:49 +02:00
type_qualifier = NULL;
obstack_free (&temp_parse_space, NULL);
obstack_init (&temp_parse_space);
return yyparse ();
2002-06-04 17:28:49 +02:00
}
Remove la_error While working on the parser code, I noticed that yyerror is exported from each parser. It is used by this code in parse.c: TRY { if (lang->la_parser (&ps)) lang->la_error (NULL); } However, it seems to me that la_error will never be called here, because in every case, la_parser throws an exception on error -- each implementation of yyerror just calls error. So, this patch removes la_error and makes all the yyerror functions static. This is handy primarily because it makes it simpler to make the expression parsers pure. Tested by the buildbot. gdb/ChangeLog 2018-06-18 Tom Tromey <tom@tromey.com> * rust-lang.h (rust_yyerror): Don't declare. * rust-lang.c (rust_language_defn): Update. * rust-exp.y (yyerror): Now static. * parse.c (parse_exp_in_context_1): Update. * p-lang.h (p_yyerror): Don't declare. * p-lang.c (p_language_defn): Update. * p-exp.y (yyerror): Now static. * opencl-lang.c (opencl_language_defn): Update. * objc-lang.c (objc_language_defn): Update. * m2-lang.h (m2_yyerror): Don't declare. * m2-lang.c (m2_language_defn): Update. * m2-exp.y (yyerror): Now static. * language.h (struct language_defn) <la_error>: Remove. * language.c (unk_lang_error): Remove. (unknown_language_defn, auto_language_defn): Remove. * go-lang.h (go_yyerror): Don't declare. * go-lang.c (go_language_defn): Update. * go-exp.y (yyerror): Now static. * f-lang.h (f_yyerror): Don't declare. * f-lang.c (f_language_defn): Update. * f-exp.y (yyerror): Now static. * d-lang.h (d_yyerror): Don't declare. * d-lang.c (d_language_defn): Update. * d-exp.y (yyerror): Now static. * c-lang.h (c_yyerror): Don't declare. * c-lang.c (c_language_defn, cplus_language_defn) (asm_language_defn, minimal_language_defn): Update. * c-exp.y (yyerror): Now static. * ada-lang.h (ada_yyerror): Don't declare. * ada-lang.c (ada_language_defn): Update. * ada-exp.y (yyerror): Now static.
2018-06-02 07:02:37 +02:00
static void
-Wwrite-strings: The Rest This is the remainder boring constification that all looks more of less borderline obvious IMO. gdb/ChangeLog: 2017-04-05 Pedro Alves <palves@redhat.com> * ada-exp.y (yyerror): Constify. * ada-lang.c (bound_name, get_selections) (ada_variant_discrim_type) (ada_variant_discrim_name, ada_value_struct_elt) (ada_lookup_struct_elt_type, is_unchecked_variant) (ada_which_variant_applies, standard_exc, ada_get_next_arg) (catch_ada_exception_command_split) (catch_ada_assert_command_split, catch_assert_command) (ada_op_name): Constify. * ada-lang.h (ada_yyerror, get_selections) (ada_variant_discrim_name, ada_value_struct_elt): Constify. * arc-tdep.c (arc_print_frame_cache): Constify. * arm-tdep.c (arm_skip_stub): Constify. * ax-gdb.c (gen_binop, gen_struct_ref_recursive, gen_struct_ref) (gen_aggregate_elt_ref): Constify. * bcache.c (print_bcache_statistics): Constify. * bcache.h (print_bcache_statistics): Constify. * break-catch-throw.c (catch_exception_command_1): * breakpoint.c (struct ep_type_description::description): Constify. (add_solib_catchpoint): Constify. (catch_fork_command_1): Add cast. (add_catch_command): Constify. * breakpoint.h (add_catch_command, add_solib_catchpoint): Constify. * bsd-uthread.c (bsd_uthread_state): Constify. * buildsym.c (patch_subfile_names): Constify. * buildsym.h (next_symbol_text_func, patch_subfile_names): Constify. * c-exp.y (yyerror): Constify. (token::oper): Constify. * c-lang.h (c_yyerror, cp_print_class_member): Constify. * c-varobj.c (cplus_describe_child): Constify. * charset.c (find_charset_names): Add cast. (find_charset_names): Constify array and add const_cast. * cli/cli-cmds.c (complete_command, cd_command): Constify. (edit_command): Constify. * cli/cli-decode.c (lookup_cmd): Constify. * cli/cli-dump.c (dump_memory_command, dump_value_command): Constify. (struct dump_context): Constify. (add_dump_command, restore_command): Constify. * cli/cli-script.c (get_command_line): Constify. * cli/cli-script.h (get_command_line): Constify. * cli/cli-utils.c (check_for_argument): Constify. * cli/cli-utils.h (check_for_argument): Constify. * coff-pe-read.c (struct read_pe_section_data): Constify. * command.h (lookup_cmd): Constify. * common/print-utils.c (decimal2str): Constify. * completer.c (gdb_print_filename): Constify. * corefile.c (set_gnutarget): Constify. * cp-name-parser.y (yyerror): Constify. * cp-valprint.c (cp_print_class_member): Constify. * cris-tdep.c (cris_register_name, crisv32_register_name): Constify. * d-exp.y (yyerror): Constify. (struct token::oper): Constify. * d-lang.h (d_yyerror): Constify. * dbxread.c (struct header_file_location::name): Constify. (add_old_header_file, add_new_header_file, last_function_name) (dbx_next_symbol_text, add_bincl_to_list) (find_corresponding_bincl_psymtab, set_namestring) (find_stab_function_addr, read_dbx_symtab, start_psymtab) (dbx_end_psymtab, read_ofile_symtab, process_one_symbol): * defs.h (command_line_input, print_address_symbolic) (deprecated_readline_begin_hook): Constify. * dwarf2read.c (anonymous_struct_prefix, dwarf_bool_name): Constify. * event-top.c (handle_line_of_input): Constify and add cast. * exceptions.c (catch_errors): Constify. * exceptions.h (catch_errors): Constify. * expprint.c (print_subexp_standard, op_string, op_name) (op_name_standard, dump_raw_expression, dump_raw_expression): * expression.h (op_name, op_string, dump_raw_expression): Constify. * f-exp.y (yyerror): Constify. (struct token::oper): Constify. (struct f77_boolean_val::name): Constify. * f-lang.c (f_word_break_characters): Constify. * f-lang.h (f_yyerror): Constify. * fork-child.c (fork_inferior): Add cast. * frv-tdep.c (struct gdbarch_tdep::register_names): Constify. (new_variant): Constify. * gdbarch.sh (pstring_ptr, pstring_list): Constify. * gdbarch.c: Regenerate. * gdbcore.h (set_gnutarget): Constify. * go-exp.y (yyerror): Constify. (token::oper): Constify. * go-lang.h (go_yyerror): Constify. * go32-nat.c (go32_sysinfo): Constify. * guile/scm-breakpoint.c (gdbscm_breakpoint_expression): Constify. * guile/scm-cmd.c (cmdscm_function): Constify. * guile/scm-param.c (pascm_param_value): Constify. * h8300-tdep.c (h8300_register_name, h8300s_register_name) (h8300sx_register_name): Constify. * hppa-tdep.c (hppa32_register_name, hppa64_register_name): Constify. * ia64-tdep.c (ia64_register_names): Constify. * infcmd.c (construct_inferior_arguments): Constify. (path_command, attach_post_wait): Constify. * language.c (show_range_command, show_case_command) (unk_lang_error): Constify. * language.h (language_defn::la_error) (language_defn::la_name_of_this): Constify. * linespec.c (decode_line_2): Constify. * linux-thread-db.c (thread_db_err_str): Constify. * lm32-tdep.c (lm32_register_name): Constify. * m2-exp.y (yyerror): Constify. * m2-lang.h (m2_yyerror): Constify. * m32r-tdep.c (m32r_register_names): Constify and make static. * m68hc11-tdep.c (m68hc11_register_names): Constify. * m88k-tdep.c (m88k_register_name): Constify. * macroexp.c (appendmem): Constify. * mdebugread.c (fdr_name, add_data_symbol, parse_type) (upgrade_type, parse_external, parse_partial_symbols) (mdebug_next_symbol_text, cross_ref, mylookup_symbol, new_psymtab) (new_symbol): Constify. * memattr.c (mem_info_command): Constify. * mep-tdep.c (register_name_from_keyword): Constify. * mi/mi-cmd-env.c (mi_cmd_env_path, _initialize_mi_cmd_env): Constify. * mi/mi-cmd-stack.c (list_args_or_locals): Constify. * mi/mi-cmd-var.c (mi_cmd_var_show_attributes): Constify. * mi/mi-main.c (captured_mi_execute_command): Constify and add cast. (mi_execute_async_cli_command): Constify. * mips-tdep.c (mips_register_name): Constify. * mn10300-tdep.c (register_name, mn10300_generic_register_name) (am33_register_name, am33_2_register_name) * moxie-tdep.c (moxie_register_names): Constify. * nat/linux-osdata.c (osdata_type): Constify fields. * nto-tdep.c (nto_parse_redirection): Constify. * objc-lang.c (lookup_struct_typedef, lookup_objc_class) (lookup_child_selector): Constify. (objc_methcall::name): Constify. * objc-lang.h (lookup_objc_class, lookup_child_selector) (lookup_struct_typedef): Constify. * objfiles.c (pc_in_section): Constify. * objfiles.h (pc_in_section): Constify. * p-exp.y (struct token::oper): Constify. (yyerror): Constify. * p-lang.h (pascal_yyerror): Constify. * parser-defs.h (op_name_standard): Constify. (op_print::string): Constify. (exp_descriptor::op_name): Constify. * printcmd.c (print_address_symbolic): Constify. * psymtab.c (print_partial_symbols): Constify. * python/py-breakpoint.c (stop_func): Constify. (bppy_get_expression): Constify. * python/py-cmd.c (cmdpy_completer::name): Constify. (cmdpy_function): Constify. * python/py-event.c (evpy_add_attribute) (gdbpy_initialize_event_generic): Constify. * python/py-event.h (evpy_add_attribute) (gdbpy_initialize_event_generic): Constify. * python/py-evts.c (add_new_registry): Constify. * python/py-finishbreakpoint.c (outofscope_func): Constify. * python/py-framefilter.c (get_py_iter_from_func): Constify. * python/py-inferior.c (get_buffer): Add cast. * python/py-param.c (parm_constant::name): Constify. * python/py-unwind.c (fprint_frame_id): Constify. * python/python.c (gdbpy_parameter_value): Constify. * remote-fileio.c (remote_fio_func_map): Make 'name' const. * remote.c (memory_packet_config::name): Constify. (show_packet_config_cmd, remote_write_bytes) (remote_buffer_add_string): * reverse.c (exec_reverse_once): Constify. * rs6000-tdep.c (variant::name, variant::description): Constify. * rust-exp.y (rustyyerror): Constify. * rust-lang.c (rust_op_name): Constify. * rust-lang.h (rustyyerror): Constify. * serial.h (serial_ops::name): Constify. * sh-tdep.c (sh_sh_register_name, sh_sh3_register_name) (sh_sh3e_register_name, sh_sh2e_register_name) (sh_sh2a_register_name, sh_sh2a_nofpu_register_name) (sh_sh_dsp_register_name, sh_sh3_dsp_register_name) (sh_sh4_register_name, sh_sh4_nofpu_register_name) (sh_sh4al_dsp_register_name): Constify. * sh64-tdep.c (sh64_register_name): Constify. * solib-darwin.c (lookup_symbol_from_bfd): Constify. * spu-tdep.c (spu_register_name, info_spu_dma_cmdlist): Constify. * stabsread.c (patch_block_stabs, read_type_number) (ref_map::stabs, ref_add, process_reference) (symbol_reference_defined, define_symbol, define_symbol) (error_type, read_type, read_member_functions, read_cpp_abbrev) (read_one_struct_field, read_struct_fields, read_baseclasses) (read_tilde_fields, read_struct_type, read_array_type) (read_enum_type, read_sun_builtin_type, read_sun_floating_type) (read_huge_number, read_range_type, read_args, common_block_start) (find_name_end): Constify. * stabsread.h (common_block_start, define_symbol) (process_one_symbol, symbol_reference_defined, ref_add): * symfile.c (get_section_index, add_symbol_file_command): * symfile.h (get_section_index): Constify. * target-descriptions.c (tdesc_type::name): Constify. (tdesc_free_type): Add cast. * target.c (find_default_run_target): (add_deprecated_target_alias, find_default_run_target) (target_announce_detach): Constify. (do_option): Constify. * target.h (add_deprecated_target_alias): Constify. * thread.c (print_thread_info_1): Constify. * top.c (deprecated_readline_begin_hook, command_line_input): Constify. (init_main): Add casts. * top.h (handle_line_of_input): Constify. * tracefile-tfile.c (tfile_write_uploaded_tsv): Constify. * tracepoint.c (tvariables_info_1, trace_status_mi): Constify. (tfind_command): Rename to ... (tfind_command_1): ... this and constify. (tfind_command): New function. (tfind_end_command, tfind_start_command): Adjust. (encode_source_string): Constify. * tracepoint.h (encode_source_string): Constify. * tui/tui-data.c (tui_partial_win_by_name): Constify. * tui/tui-data.h (tui_partial_win_by_name): Constify. * tui/tui-source.c (tui_set_source_content_nil): Constify. * tui/tui-source.h (tui_set_source_content_nil): Constify. * tui/tui-win.c (parse_scrolling_args): Constify. * tui/tui-windata.c (tui_erase_data_content): Constify. * tui/tui-windata.h (tui_erase_data_content): Constify. * tui/tui-winsource.c (tui_erase_source_content): Constify. * tui/tui.c (tui_enable): Add cast. * utils.c (defaulted_query): Constify. (init_page_info): Add cast. (puts_debug, subset_compare): Constify. * utils.h (subset_compare): Constify. * varobj.c (varobj_format_string): Constify. * varobj.h (varobj_format_string): Constify. * vax-tdep.c (vax_register_name): Constify. * windows-nat.c (windows_detach): Constify. * xcoffread.c (process_linenos, xcoff_next_symbol_text): Constify. * xml-support.c (gdb_xml_end_element): Constify. * xml-tdesc.c (tdesc_start_reg): Constify. * xstormy16-tdep.c (xstormy16_register_name): Constify. * xtensa-tdep.c (xtensa_find_register_by_name): Constify. * xtensa-tdep.h (xtensa_register_t::name): Constify. gdb/gdbserver/ChangeLog: 2017-04-05 Pedro Alves <palves@redhat.com> * gdbreplay.c (sync_error): Constify. * linux-x86-low.c (push_opcode): Constify.
2017-04-05 20:21:37 +02:00
yyerror (const char *msg)
2002-06-04 17:28:49 +02:00
{
error (_("Error in expression, near `%s'."), pstate->lexptr);
2002-06-04 17:28:49 +02:00
}
/* Emit expression to access an instance of SYM, in block BLOCK (if
local variable watchpoint not deleted after leaving scope When debugging an Ada program, and inserting a watchpoint tracking a local variable, the watchpoint doesn't get automatically deleted upon leaving that variable's scope. This watchpoint then starts creating problems later on, when trying to resume the program's execution from a location outside of the watchpoint's scope: (gdb) c Continuing. Breakpoint 2, foo_p708_025 () at foo_p708_025.adb:7 7 Do_Nothing (Val); (gdb) n No frame is currently executing in block pck.get_val. Command aborted. (gdb) c Continuing. No frame is currently executing in block pck.get_val. Command aborted. The expected output is the following: - The program's execution after the first continue should stop as soon as we reach the end of the watchpoint's scope, and the debugger should be deleting it. - Then we can continue until reaching breakpoint 2 above; - After which we should be able to do next/continue as usual. The reason the watchpoint is not automatically deleted at scope exit is because the watchpoint is not marked as being scope-specific (b->exp_valid_block is equal NULL), and this is because the symbol lookup for our local variable failed to set the innermost_block global variable during the lookup. More precisely, if we look at watch_command_1, we do the following: innermost_block = NULL; [...] exp = parse_exp_1 (&arg, 0, 0, 0); [...] exp_valid_block = innermost_block; Currently, innermost_block stays NULL after the call to parse_exp_1. Digging further, this innermost_block is typically set during symbol lookup when the symbol is considered to have a frame-relative address. For instance, in c-exp.y, we see some code like the following: if (symbol_read_needs_frame (sym.symbol)) { if (innermost_block == 0 || contained_in (sym.block, innermost_block)) innermost_block = sym.block; } We actually have the exact same mechanism in ada-exp.y, except that it vhas accidently been turned off. See write_var_from_sym, where we start with: if (orig_left_context == NULL && symbol_read_needs_frame (sym)) { if (innermost_block == 0 || contained_in (block, innermost_block)) innermost_block = block; } In this case, orig_left_context is a parameter, and looking at the point of call in write_var_or_type, we see: if (nsyms == 1) { write_var_from_sym (par_state, block, syms[0].block, syms[0].symbol); In the call above, the paramater we are interested in is "block", which is a parameter for write_var_or_type as well, except we explicitly override its value at the beginning when found to be NULL: if (block == NULL) block = expression_context_block; So the block we pass to write_var_from_sym is not NULL, and we therefore don't set innermost_block, which leads to the watchpoint no longer being marked as scope-specific. The handling of orig_left_context in write_var_from_sym was there to handle the case where a user writes an expression where the symbol is qualified with a scope (Eg: "function::variable"). But it appears that handling this is specifically here is no longer necessary, so this patch simply removes that parameter and the associated check, and then updates all the points of calls. Interestingly, this also affects GDB/MI, and in particular varobjs, because local variables are now properly reported as having a block, which causes the associated varob to have a "thread-id" field. This patch also adjusts a couple of Ada/gdb-mi tests. gdb/ChangeLog: * ada-exp.y (write_var_from_sym): Remove parameter "orig_left_context". Update all callers. gdb/testsuite/ChangeLog: * gdb.ada/scoped_watch: New testcase. * gdb.ada/watch_arg.exp: Adjust expected behavior to the behavior which is actually correct. * gdb.ada/mi_interface.exp: Add missing thread-id in expected varobj. * gdb.ada/mi_var_array.exp: Add missing thread-id in expected varobj.
2017-03-03 17:31:13 +01:00
non-NULL). */
2002-06-04 17:28:49 +02:00
static void
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_var_from_sym (struct parser_state *par_state,
* ada-exp.y (write_object_renaming, write_var_or_type) (write_ambiguous_var, write_var_from_sym): Make blocks const. * ada-lang.c (replace_operator_with_call) (find_old_style_renaming_symbol): Make blocks const. * ada-lang.h (ada_find_renaming_symbol): Update. (struct ada_symbol_info) <block>: Now const. * breakpoint.c (watch_command_1): Update. * breakpoint.h (struct watchpoint) <exp_valid_block, cond_exp_valid_block>: Now const. * c-exp.y (classify_inner_name, classify_name): Make block argument const. * expprint.c (print_subexp_standard) <OP_VAR_VALUE>: Make 'b' const. * expression.h (innermost_block, parse_exp_1): Update. (union exp_element) <block>: Now const. * gdbtypes.c (lookup_template_type, lookup_enum, lookup_union) (lookup_struct): Make block argument const. * gdbtypes.h (lookup_template_type): Update. * go-exp.y (classify_name, classify_packaged_name) (package_name_p): Make block argument const. * objc-lang.c (lookup_struct_typedef): Make block argument const. * objc-lang.h (lookup_struct_typedef): Update. * parse.c (parse_exp_in_context, parse_exp_1) (write_exp_elt_block): Make block arguments const. (expression_context_block, innermost_block): Now const. * parser-defs.h (write_exp_elt_block): Update. (expression_context_block, innermost_block, block_found): Now const. * printcmd.c (struct display) <block>: Now const. * symtab.h (lookup_struct, lookup_union, lookup_enum): Update. * valops.c (address_of_variable): Make block argument const. * value.h (value_of_variable): Update. * varobj.c (struct varobj_root) <valid_block>: Now const.
2012-12-03 20:59:14 +01:00
const struct block *block,
struct symbol *sym)
2002-06-04 17:28:49 +02:00
{
local variable watchpoint not deleted after leaving scope When debugging an Ada program, and inserting a watchpoint tracking a local variable, the watchpoint doesn't get automatically deleted upon leaving that variable's scope. This watchpoint then starts creating problems later on, when trying to resume the program's execution from a location outside of the watchpoint's scope: (gdb) c Continuing. Breakpoint 2, foo_p708_025 () at foo_p708_025.adb:7 7 Do_Nothing (Val); (gdb) n No frame is currently executing in block pck.get_val. Command aborted. (gdb) c Continuing. No frame is currently executing in block pck.get_val. Command aborted. The expected output is the following: - The program's execution after the first continue should stop as soon as we reach the end of the watchpoint's scope, and the debugger should be deleting it. - Then we can continue until reaching breakpoint 2 above; - After which we should be able to do next/continue as usual. The reason the watchpoint is not automatically deleted at scope exit is because the watchpoint is not marked as being scope-specific (b->exp_valid_block is equal NULL), and this is because the symbol lookup for our local variable failed to set the innermost_block global variable during the lookup. More precisely, if we look at watch_command_1, we do the following: innermost_block = NULL; [...] exp = parse_exp_1 (&arg, 0, 0, 0); [...] exp_valid_block = innermost_block; Currently, innermost_block stays NULL after the call to parse_exp_1. Digging further, this innermost_block is typically set during symbol lookup when the symbol is considered to have a frame-relative address. For instance, in c-exp.y, we see some code like the following: if (symbol_read_needs_frame (sym.symbol)) { if (innermost_block == 0 || contained_in (sym.block, innermost_block)) innermost_block = sym.block; } We actually have the exact same mechanism in ada-exp.y, except that it vhas accidently been turned off. See write_var_from_sym, where we start with: if (orig_left_context == NULL && symbol_read_needs_frame (sym)) { if (innermost_block == 0 || contained_in (block, innermost_block)) innermost_block = block; } In this case, orig_left_context is a parameter, and looking at the point of call in write_var_or_type, we see: if (nsyms == 1) { write_var_from_sym (par_state, block, syms[0].block, syms[0].symbol); In the call above, the paramater we are interested in is "block", which is a parameter for write_var_or_type as well, except we explicitly override its value at the beginning when found to be NULL: if (block == NULL) block = expression_context_block; So the block we pass to write_var_from_sym is not NULL, and we therefore don't set innermost_block, which leads to the watchpoint no longer being marked as scope-specific. The handling of orig_left_context in write_var_from_sym was there to handle the case where a user writes an expression where the symbol is qualified with a scope (Eg: "function::variable"). But it appears that handling this is specifically here is no longer necessary, so this patch simply removes that parameter and the associated check, and then updates all the points of calls. Interestingly, this also affects GDB/MI, and in particular varobjs, because local variables are now properly reported as having a block, which causes the associated varob to have a "thread-id" field. This patch also adjusts a couple of Ada/gdb-mi tests. gdb/ChangeLog: * ada-exp.y (write_var_from_sym): Remove parameter "orig_left_context". Update all callers. gdb/testsuite/ChangeLog: * gdb.ada/scoped_watch: New testcase. * gdb.ada/watch_arg.exp: Adjust expected behavior to the behavior which is actually correct. * gdb.ada/mi_interface.exp: Add missing thread-id in expected varobj. * gdb.ada/mi_var_array.exp: Add missing thread-id in expected varobj.
2017-03-03 17:31:13 +01:00
if (symbol_read_needs_frame (sym))
Move innermost_block_tracker global to parse_state This changes the parsing API so that callers that are interested in tracking the innermost block must instantiate an innermost_block_tracker and pass it in. Then, a pointer to this object is stored in the parser_state. 2019-04-04 Tom Tromey <tom@tromey.com> * varobj.c (varobj_create): Update. * rust-exp.y (struct rust_parser) <update_innermost_block, lookup_symbol>: New methods. (rust_parser::update_innermost_block, rust_parser::lookup_symbol): Rename. (rust_parser::rust_lookup_type) (rust_parser::convert_ast_to_expression, rust_lex_tests): Update. * printcmd.c (display_command, do_one_display): Update. * parser-defs.h (struct parser_state) <parser_state>: Add "tracker" parameter. (block_tracker): New member. (class innermost_block_tracker) <innermost_block_tracker>: Add "types" parameter. <reset>: Remove method. (innermost_block): Don't declare. (null_post_parser): Update. * parse.c (innermost_block): Remove global. (write_dollar_variable): Update. (parse_exp_1, parse_exp_in_context): Add "tracker" parameter. Remove "tracker_types" parameter. (parse_expression): Add "tracker" parameter. (parse_expression_for_completion): Update. (null_post_parser): Add "tracker" parameter. * p-exp.y: Update rules. * m2-exp.y: Update rules. * language.h (struct language_defn) <la_post_parser>: Add "tracker" parameter. * go-exp.y: Update rules. * f-exp.y: Update rules. * expression.h (parse_expression, parse_exp_1): Add "tracker" parameter. * d-exp.y: Update rules. * c-exp.y: Update rules. * breakpoint.c (set_breakpoint_condition): Create an innermost_block_tracker. (watch_command_1): Likewise. * ada-lang.c (resolve): Add "tracker" parameter. (resolve_subexp): Likewise. * ada-exp.y (write_var_from_sym): Update.
2019-04-01 01:20:24 +02:00
par_state->block_tracker->update (block, INNERMOST_BLOCK_FOR_SYMBOLS);
2002-06-04 17:28:49 +02:00
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_exp_elt_opcode (par_state, OP_VAR_VALUE);
write_exp_elt_block (par_state, block);
write_exp_elt_sym (par_state, sym);
write_exp_elt_opcode (par_state, OP_VAR_VALUE);
2002-06-04 17:28:49 +02:00
}
/* Write integer or boolean constant ARG of type TYPE. */
2002-06-04 17:28:49 +02:00
static void
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_int (struct parser_state *par_state, LONGEST arg, struct type *type)
2002-06-04 17:28:49 +02:00
{
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_exp_elt_opcode (par_state, OP_LONG);
write_exp_elt_type (par_state, type);
write_exp_elt_longcst (par_state, arg);
write_exp_elt_opcode (par_state, OP_LONG);
}
2002-06-04 17:28:49 +02:00
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
/* Write an OPCODE, string, OPCODE sequence to the current expression. */
static void
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_exp_op_with_string (struct parser_state *par_state,
enum exp_opcode opcode, struct stoken token)
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
{
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_exp_elt_opcode (par_state, opcode);
write_exp_string (par_state, token);
write_exp_elt_opcode (par_state, opcode);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
}
* ada-lang.h (ada_renaming_category): New enumerated type. (ada_lookup_encoded_symbol): Declare. (ada_parse_renaming): Declare. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete declarations. * ada-lang.c (ada_parse_renaming): New function to concentrate extraction of information from renaming symbols. (parse_old_style_renaming): New function to concentrate extraction of old-style (purely type-based) renaming information. (renaming_is_visible): Rename to... (old_renaming_is_invisible): Rename and change sense of renaming_is_visible. (remove_out_of_scope_renamings): Rename to... (remove_irrelevant_renamings): Renames remove_out_of_scope_renamings and augments with additional logic to handle cases where the same object renaming is encoded both as a reference variable and an encoded renaming. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete definitions. (ada_lookup_encoded_symbol): New function factored out of ada_lookup_symbol. (ada_lookup_symbol): Reimplement to call ada_lookup_encoded_symbol. (wild_match): Don't reject perfect match of prefix. (ada_find_renaming_symbol): Factor old-style renaming logic into find_old_style_renaming_symbol. (find_old_style_renaming_symbol): New name for content of old ada_find_renaming_symbol. (ada_prefer_type): Reimplement not to use ada_renaming_type. * ada-exp.y (write_object_renaming): Change interface. Reimplement to use new arguments and ada_parse_renaming. Correct blocks used to find array index. (write_var_or_type): Reimplement to use ada_parse_renaming.
2007-12-21 12:50:11 +01:00
/* Emit expression corresponding to the renamed object named
* designated by RENAMED_ENTITY[0 .. RENAMED_ENTITY_LEN-1] in the
* context of ORIG_LEFT_CONTEXT, to which is applied the operations
* encoded by RENAMING_EXPR. MAX_DEPTH is the maximum number of
* cascaded renamings to allow. If ORIG_LEFT_CONTEXT is null, it
* defaults to the currently selected block. ORIG_SYMBOL is the
* symbol that originally encoded the renaming. It is needed only
* because its prefix also qualifies any index variables used to index
* or slice an array. It should not be necessary once we go to the
* new encoding entirely (FIXME pnh 7/20/2007). */
2002-06-04 17:28:49 +02:00
static void
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_object_renaming (struct parser_state *par_state,
const struct block *orig_left_context,
* ada-lang.h (ada_renaming_category): New enumerated type. (ada_lookup_encoded_symbol): Declare. (ada_parse_renaming): Declare. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete declarations. * ada-lang.c (ada_parse_renaming): New function to concentrate extraction of information from renaming symbols. (parse_old_style_renaming): New function to concentrate extraction of old-style (purely type-based) renaming information. (renaming_is_visible): Rename to... (old_renaming_is_invisible): Rename and change sense of renaming_is_visible. (remove_out_of_scope_renamings): Rename to... (remove_irrelevant_renamings): Renames remove_out_of_scope_renamings and augments with additional logic to handle cases where the same object renaming is encoded both as a reference variable and an encoded renaming. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete definitions. (ada_lookup_encoded_symbol): New function factored out of ada_lookup_symbol. (ada_lookup_symbol): Reimplement to call ada_lookup_encoded_symbol. (wild_match): Don't reject perfect match of prefix. (ada_find_renaming_symbol): Factor old-style renaming logic into find_old_style_renaming_symbol. (find_old_style_renaming_symbol): New name for content of old ada_find_renaming_symbol. (ada_prefer_type): Reimplement not to use ada_renaming_type. * ada-exp.y (write_object_renaming): Change interface. Reimplement to use new arguments and ada_parse_renaming. Correct blocks used to find array index. (write_var_or_type): Reimplement to use ada_parse_renaming.
2007-12-21 12:50:11 +01:00
const char *renamed_entity, int renamed_entity_len,
const char *renaming_expr, int max_depth)
2002-06-04 17:28:49 +02:00
{
char *name;
2002-06-04 17:28:49 +02:00
enum { SIMPLE_INDEX, LOWER_BOUND, UPPER_BOUND } slice_state;
Replace the block_found global with explicit data-flow As Pedro suggested on gdb-patches@ (see https://sourceware.org/ml/gdb-patches/2015-05/msg00714.html), this change makes symbol lookup functions return a structure that includes both the symbol found and the block in which it was found. This makes it possible to get rid of the block_found global variable and thus makes block hunting explicit. gdb/ * ada-exp.y (write_object_renaming): Replace struct ada_symbol_info with struct block_symbol. Update field references accordingly. (block_lookup, select_possible_type_sym): Likewise. (find_primitive_type): Likewise. Also update call to ada_lookup_symbol to extract the symbol itself. (write_var_or_type, write_name_assoc): Likewise. * ada-lang.h (struct ada_symbol_info): Remove. (ada_lookup_symbol_list): Replace struct ada_symbol_info with struct block_symbol. (ada_lookup_encoded_symbol, user_select_syms): Likewise. (ada_lookup_symbol): Return struct block_symbol instead of a mere symbol. * ada-lang.c (defns_collected): Replace struct ada_symbol_info with struct block_symbol. (resolve_subexp, ada_resolve_function, sort_choices, user_select_syms, is_nonfunction, add_defn_to_vec, num_defns_collected, defns_collected, symbols_are_identical_enums, remove_extra_symbols, remove_irrelevant_renamings, add_lookup_symbol_list_worker, ada_lookup_symbol_list, ada_iterate_over_symbols, ada_lookup_encoded_symbol, get_var_value): Likewise. (ada_lookup_symbol): Return a block_symbol instead of a mere symbol. Replace struct ada_symbol_info with struct block_symbol. (ada_lookup_symbol_nonlocal): Likewise. (standard_lookup): Make block passing explicit through lookup_symbol_in_language. * ada-tasks.c (get_tcb_types_info): Update the calls to lookup_symbol_in_language to extract the mere symbol out of the returned value. (ada_tasks_inferior_data_sniffer): Likewise. * ax-gdb.c (gen_static_field): Likewise for the call to lookup_symbol. (gen_maybe_namespace_elt): Deal with struct symbol_in_block from lookup functions. (gen_expr): Likewise. * c-exp.y: Likewise. Remove uses of block_found. (lex_one_token, classify_inner_name, c_print_token): Likewise. (classify_name): Likewise. Rename the "sym" local variable to "bsym". * c-valprint.c (print_unpacked_pointer): Likewise. * compile/compile-c-symbols.c (convert_symbol_sym): Promote the "sym" parameter from struct symbol * to struct block_symbol. Use it to remove uses of block_found. Deal with struct symbol_in_block from lookup functions. (gcc_convert_symbol): Likewise. Update the call to convert_symbol_sym. * compile/compile-object-load.c (compile_object_load): Deal with struct symbol_in_block from lookup functions. * cp-namespace.c (cp_lookup_nested_symbol_1, cp_lookup_nested_symbol, cp_lookup_bare_symbol, cp_search_static_and_baseclasses, cp_lookup_symbol_in_namespace, cp_lookup_symbol_via_imports, cp_lookup_symbol_imports_or_template, cp_lookup_symbol_via_all_imports, cp_lookup_symbol_namespace, lookup_namespace_scope, cp_lookup_nonlocal, find_symbol_in_baseclass): Return struct symbol_in_block instead of mere symbols and deal with struct symbol_in_block from lookup functions. * cp-support.c (inspect_type, replace_typedefs, cp_lookup_rtti_type): Deal with struct symbol_in_block from lookup functions. * cp-support.h (cp_lookup_symbol_nonlocal, cp_lookup_symbol_from_namespace, cp_lookup_symbol_imports_or_template, cp_lookup_nested_symbol): Return struct symbol_in_block instead of mere symbols. * d-exp.y (d_type_from_name, d_module_from_name, push_variable, push_module_name): Deal with struct symbol_in_block from lookup functions. Remove uses of block_found. * eval.c (evaluate_subexp_standard): Update call to cp_lookup_symbol_namespace. * f-exp.y: Deal with struct symbol_in_block from lookup functions. Remove uses of block_found. (yylex): Likewise. * gdbtypes.c (lookup_typename, lookup_struct, lookup_union, lookup_enum, lookup_template_type, check_typedef): Deal with struct symbol_in_block from lookup functions. * guile/scm-frame.c (gdbscm_frame_read_var): Likewise. * guile/scm-symbol.c (gdbscm_lookup_symbol): Likewise. (gdbscm_lookup_global_symbol): Likewise. * gnu-v3-abi.c (gnuv3_get_typeid_type): Likewise. * go-exp.y: Likewise. Remove uses of block_found. (package_name_p, classify_packaged_name, classify_name): Likewise. * infrun.c (insert_exception_resume_breakpoint): Likewise. * jv-exp.y (push_variable): Likewise. * jv-lang.c (java_lookup_class, get_java_object_type): Likewise. * language.c (language_bool_type): Likewise. * language.h (struct language_defn): Update la_lookup_symbol_nonlocal to return a struct symbol_in_block rather than a mere symbol. * linespec.c (find_label_symbols): Deal with struct symbol_in_block from lookup functions. * m2-exp.y: Likewise. Remove uses of block_found. (yylex): Likewise. * mi/mi-cmd-stack.c (list_args_or_locals): Likewise. * objc-lang.c (lookup_struct_typedef, find_imps): Likewise. * p-exp.y: Likewise. Remove uses of block_found. (yylex): Likewise. * p-valprint.c (pascal_val_print): Likewise. * parse.c (write_dollar_variable): Likewise. Remove uses of block_found. * parser-defs.h (struct symtoken): Turn the SYM field into a struct symbol_in_block. * printcmd.c (address_info): Deal with struct symbol_in_block from lookup functions. * python/py-frame.c (frapy_read_var): Likewise. * python/py-symbol.c (gdbpy_lookup_symbol, gdbpy_lookup_global_symbol): Likewise. * skip.c (skip_function_command): Likewise. * solib-darwin.c (darwin_lookup_lib_symbol): Return a struct symbol_in_block instead of a mere symbol. * solib-spu.c (spu_lookup_lib_symbol): Likewise. * solib-svr4.c (elf_lookup_lib_symbol): Likewise. * solib.c (solib_global_lookup): Likewise. * solist.h (solib_global_lookup): Likewise. (struct target_so_ops): Update lookup_lib_global_symbol to return a struct symbol_in_block rather than a mere symbol. * source.c (select_source_symtab): Deal with struct symbol_in_block from lookup functions. * stack.c (print_frame_args, iterate_over_block_arg_vars): Likewise. * symfile.c (set_initial_language): Likewise. * symtab.c (SYMBOL_LOOKUP_FAILED): Turn into a struct symbol_in_block. (SYMBOL_LOOKUP_FAILED_P): New predicate as a macro. (struct symbol_cache_slot): Turn the FOUND field into a struct symbol_in_block. (block_found): Remove. (eq_symbol_entry): Update to deal with struct symbol_in_block in cache slots. (symbol_cache_lookup): Return a struct symbol_in_block rather than a mere symbol. (symbol_cache_mark_found): Add a BLOCK parameter to fill appropriately the cache slots. Update callers. (symbol_cache_dump): Update cache slots handling to the type change. (lookup_symbol_in_language, lookup_symbol, lookup_language_this, lookup_symbol_aux, lookup_local_symbol, lookup_symbol_in_objfile, lookup_global_symbol_from_objfile, lookup_symbol_in_objfile_symtabs, lookup_symbol_in_objfile_from_linkage_name, lookup_symbol_via_quick_fns, basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block, lookup_static_symbol, lookup_global_symbol): Return a struct symbol_in_block rather than a mere symbol. Deal with struct symbol_in_block from other lookup functions. Remove uses of block_found. (lookup_symbol_in_block): Remove uses of block_found. (struct global_sym_lookup_data): Turn the RESULT field into a struct symbol_in_block. (lookup_symbol_global_iterator_cb): Update references to the RESULT field. (search_symbols): Deal with struct symbol_in_block from lookup functions. * symtab.h (struct symbol_in_block): New structure. (block_found): Remove. (lookup_symbol_in_language, lookup_symbol, basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block, looku_static_symbol, lookup_global_symbol, lookup_symbol_in_block, lookup_language_this, lookup_global_symbol_from_objfile): Return a struct symbol_in_block rather than just a mere symbol. Update comments to remove mentions of block_found. * valops.c (find_function_in_inferior, value_struct_elt_for_reference, value_maybe_namespace_elt, value_of_this): Deal with struct symbol_in_block from lookup functions. * value.c (value_static_field, value_fn_field): Likewise.
2015-07-21 17:02:15 +02:00
struct block_symbol sym_info;
2002-06-04 17:28:49 +02:00
if (max_depth <= 0)
error (_("Could not find renamed symbol"));
2002-06-04 17:28:49 +02:00
if (orig_left_context == NULL)
orig_left_context = get_selected_block (NULL);
name = obstack_strndup (&temp_parse_space, renamed_entity,
renamed_entity_len);
ada_lookup_encoded_symbol (name, orig_left_context, VAR_DOMAIN, &sym_info);
Replace the block_found global with explicit data-flow As Pedro suggested on gdb-patches@ (see https://sourceware.org/ml/gdb-patches/2015-05/msg00714.html), this change makes symbol lookup functions return a structure that includes both the symbol found and the block in which it was found. This makes it possible to get rid of the block_found global variable and thus makes block hunting explicit. gdb/ * ada-exp.y (write_object_renaming): Replace struct ada_symbol_info with struct block_symbol. Update field references accordingly. (block_lookup, select_possible_type_sym): Likewise. (find_primitive_type): Likewise. Also update call to ada_lookup_symbol to extract the symbol itself. (write_var_or_type, write_name_assoc): Likewise. * ada-lang.h (struct ada_symbol_info): Remove. (ada_lookup_symbol_list): Replace struct ada_symbol_info with struct block_symbol. (ada_lookup_encoded_symbol, user_select_syms): Likewise. (ada_lookup_symbol): Return struct block_symbol instead of a mere symbol. * ada-lang.c (defns_collected): Replace struct ada_symbol_info with struct block_symbol. (resolve_subexp, ada_resolve_function, sort_choices, user_select_syms, is_nonfunction, add_defn_to_vec, num_defns_collected, defns_collected, symbols_are_identical_enums, remove_extra_symbols, remove_irrelevant_renamings, add_lookup_symbol_list_worker, ada_lookup_symbol_list, ada_iterate_over_symbols, ada_lookup_encoded_symbol, get_var_value): Likewise. (ada_lookup_symbol): Return a block_symbol instead of a mere symbol. Replace struct ada_symbol_info with struct block_symbol. (ada_lookup_symbol_nonlocal): Likewise. (standard_lookup): Make block passing explicit through lookup_symbol_in_language. * ada-tasks.c (get_tcb_types_info): Update the calls to lookup_symbol_in_language to extract the mere symbol out of the returned value. (ada_tasks_inferior_data_sniffer): Likewise. * ax-gdb.c (gen_static_field): Likewise for the call to lookup_symbol. (gen_maybe_namespace_elt): Deal with struct symbol_in_block from lookup functions. (gen_expr): Likewise. * c-exp.y: Likewise. Remove uses of block_found. (lex_one_token, classify_inner_name, c_print_token): Likewise. (classify_name): Likewise. Rename the "sym" local variable to "bsym". * c-valprint.c (print_unpacked_pointer): Likewise. * compile/compile-c-symbols.c (convert_symbol_sym): Promote the "sym" parameter from struct symbol * to struct block_symbol. Use it to remove uses of block_found. Deal with struct symbol_in_block from lookup functions. (gcc_convert_symbol): Likewise. Update the call to convert_symbol_sym. * compile/compile-object-load.c (compile_object_load): Deal with struct symbol_in_block from lookup functions. * cp-namespace.c (cp_lookup_nested_symbol_1, cp_lookup_nested_symbol, cp_lookup_bare_symbol, cp_search_static_and_baseclasses, cp_lookup_symbol_in_namespace, cp_lookup_symbol_via_imports, cp_lookup_symbol_imports_or_template, cp_lookup_symbol_via_all_imports, cp_lookup_symbol_namespace, lookup_namespace_scope, cp_lookup_nonlocal, find_symbol_in_baseclass): Return struct symbol_in_block instead of mere symbols and deal with struct symbol_in_block from lookup functions. * cp-support.c (inspect_type, replace_typedefs, cp_lookup_rtti_type): Deal with struct symbol_in_block from lookup functions. * cp-support.h (cp_lookup_symbol_nonlocal, cp_lookup_symbol_from_namespace, cp_lookup_symbol_imports_or_template, cp_lookup_nested_symbol): Return struct symbol_in_block instead of mere symbols. * d-exp.y (d_type_from_name, d_module_from_name, push_variable, push_module_name): Deal with struct symbol_in_block from lookup functions. Remove uses of block_found. * eval.c (evaluate_subexp_standard): Update call to cp_lookup_symbol_namespace. * f-exp.y: Deal with struct symbol_in_block from lookup functions. Remove uses of block_found. (yylex): Likewise. * gdbtypes.c (lookup_typename, lookup_struct, lookup_union, lookup_enum, lookup_template_type, check_typedef): Deal with struct symbol_in_block from lookup functions. * guile/scm-frame.c (gdbscm_frame_read_var): Likewise. * guile/scm-symbol.c (gdbscm_lookup_symbol): Likewise. (gdbscm_lookup_global_symbol): Likewise. * gnu-v3-abi.c (gnuv3_get_typeid_type): Likewise. * go-exp.y: Likewise. Remove uses of block_found. (package_name_p, classify_packaged_name, classify_name): Likewise. * infrun.c (insert_exception_resume_breakpoint): Likewise. * jv-exp.y (push_variable): Likewise. * jv-lang.c (java_lookup_class, get_java_object_type): Likewise. * language.c (language_bool_type): Likewise. * language.h (struct language_defn): Update la_lookup_symbol_nonlocal to return a struct symbol_in_block rather than a mere symbol. * linespec.c (find_label_symbols): Deal with struct symbol_in_block from lookup functions. * m2-exp.y: Likewise. Remove uses of block_found. (yylex): Likewise. * mi/mi-cmd-stack.c (list_args_or_locals): Likewise. * objc-lang.c (lookup_struct_typedef, find_imps): Likewise. * p-exp.y: Likewise. Remove uses of block_found. (yylex): Likewise. * p-valprint.c (pascal_val_print): Likewise. * parse.c (write_dollar_variable): Likewise. Remove uses of block_found. * parser-defs.h (struct symtoken): Turn the SYM field into a struct symbol_in_block. * printcmd.c (address_info): Deal with struct symbol_in_block from lookup functions. * python/py-frame.c (frapy_read_var): Likewise. * python/py-symbol.c (gdbpy_lookup_symbol, gdbpy_lookup_global_symbol): Likewise. * skip.c (skip_function_command): Likewise. * solib-darwin.c (darwin_lookup_lib_symbol): Return a struct symbol_in_block instead of a mere symbol. * solib-spu.c (spu_lookup_lib_symbol): Likewise. * solib-svr4.c (elf_lookup_lib_symbol): Likewise. * solib.c (solib_global_lookup): Likewise. * solist.h (solib_global_lookup): Likewise. (struct target_so_ops): Update lookup_lib_global_symbol to return a struct symbol_in_block rather than a mere symbol. * source.c (select_source_symtab): Deal with struct symbol_in_block from lookup functions. * stack.c (print_frame_args, iterate_over_block_arg_vars): Likewise. * symfile.c (set_initial_language): Likewise. * symtab.c (SYMBOL_LOOKUP_FAILED): Turn into a struct symbol_in_block. (SYMBOL_LOOKUP_FAILED_P): New predicate as a macro. (struct symbol_cache_slot): Turn the FOUND field into a struct symbol_in_block. (block_found): Remove. (eq_symbol_entry): Update to deal with struct symbol_in_block in cache slots. (symbol_cache_lookup): Return a struct symbol_in_block rather than a mere symbol. (symbol_cache_mark_found): Add a BLOCK parameter to fill appropriately the cache slots. Update callers. (symbol_cache_dump): Update cache slots handling to the type change. (lookup_symbol_in_language, lookup_symbol, lookup_language_this, lookup_symbol_aux, lookup_local_symbol, lookup_symbol_in_objfile, lookup_global_symbol_from_objfile, lookup_symbol_in_objfile_symtabs, lookup_symbol_in_objfile_from_linkage_name, lookup_symbol_via_quick_fns, basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block, lookup_static_symbol, lookup_global_symbol): Return a struct symbol_in_block rather than a mere symbol. Deal with struct symbol_in_block from other lookup functions. Remove uses of block_found. (lookup_symbol_in_block): Remove uses of block_found. (struct global_sym_lookup_data): Turn the RESULT field into a struct symbol_in_block. (lookup_symbol_global_iterator_cb): Update references to the RESULT field. (search_symbols): Deal with struct symbol_in_block from lookup functions. * symtab.h (struct symbol_in_block): New structure. (block_found): Remove. (lookup_symbol_in_language, lookup_symbol, basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block, looku_static_symbol, lookup_global_symbol, lookup_symbol_in_block, lookup_language_this, lookup_global_symbol_from_objfile): Return a struct symbol_in_block rather than just a mere symbol. Update comments to remove mentions of block_found. * valops.c (find_function_in_inferior, value_struct_elt_for_reference, value_maybe_namespace_elt, value_of_this): Deal with struct symbol_in_block from lookup functions. * value.c (value_static_field, value_fn_field): Likewise.
2015-07-21 17:02:15 +02:00
if (sym_info.symbol == NULL)
error (_("Could not find renamed variable: %s"), ada_decode (name).c_str ());
Replace the block_found global with explicit data-flow As Pedro suggested on gdb-patches@ (see https://sourceware.org/ml/gdb-patches/2015-05/msg00714.html), this change makes symbol lookup functions return a structure that includes both the symbol found and the block in which it was found. This makes it possible to get rid of the block_found global variable and thus makes block hunting explicit. gdb/ * ada-exp.y (write_object_renaming): Replace struct ada_symbol_info with struct block_symbol. Update field references accordingly. (block_lookup, select_possible_type_sym): Likewise. (find_primitive_type): Likewise. Also update call to ada_lookup_symbol to extract the symbol itself. (write_var_or_type, write_name_assoc): Likewise. * ada-lang.h (struct ada_symbol_info): Remove. (ada_lookup_symbol_list): Replace struct ada_symbol_info with struct block_symbol. (ada_lookup_encoded_symbol, user_select_syms): Likewise. (ada_lookup_symbol): Return struct block_symbol instead of a mere symbol. * ada-lang.c (defns_collected): Replace struct ada_symbol_info with struct block_symbol. (resolve_subexp, ada_resolve_function, sort_choices, user_select_syms, is_nonfunction, add_defn_to_vec, num_defns_collected, defns_collected, symbols_are_identical_enums, remove_extra_symbols, remove_irrelevant_renamings, add_lookup_symbol_list_worker, ada_lookup_symbol_list, ada_iterate_over_symbols, ada_lookup_encoded_symbol, get_var_value): Likewise. (ada_lookup_symbol): Return a block_symbol instead of a mere symbol. Replace struct ada_symbol_info with struct block_symbol. (ada_lookup_symbol_nonlocal): Likewise. (standard_lookup): Make block passing explicit through lookup_symbol_in_language. * ada-tasks.c (get_tcb_types_info): Update the calls to lookup_symbol_in_language to extract the mere symbol out of the returned value. (ada_tasks_inferior_data_sniffer): Likewise. * ax-gdb.c (gen_static_field): Likewise for the call to lookup_symbol. (gen_maybe_namespace_elt): Deal with struct symbol_in_block from lookup functions. (gen_expr): Likewise. * c-exp.y: Likewise. Remove uses of block_found. (lex_one_token, classify_inner_name, c_print_token): Likewise. (classify_name): Likewise. Rename the "sym" local variable to "bsym". * c-valprint.c (print_unpacked_pointer): Likewise. * compile/compile-c-symbols.c (convert_symbol_sym): Promote the "sym" parameter from struct symbol * to struct block_symbol. Use it to remove uses of block_found. Deal with struct symbol_in_block from lookup functions. (gcc_convert_symbol): Likewise. Update the call to convert_symbol_sym. * compile/compile-object-load.c (compile_object_load): Deal with struct symbol_in_block from lookup functions. * cp-namespace.c (cp_lookup_nested_symbol_1, cp_lookup_nested_symbol, cp_lookup_bare_symbol, cp_search_static_and_baseclasses, cp_lookup_symbol_in_namespace, cp_lookup_symbol_via_imports, cp_lookup_symbol_imports_or_template, cp_lookup_symbol_via_all_imports, cp_lookup_symbol_namespace, lookup_namespace_scope, cp_lookup_nonlocal, find_symbol_in_baseclass): Return struct symbol_in_block instead of mere symbols and deal with struct symbol_in_block from lookup functions. * cp-support.c (inspect_type, replace_typedefs, cp_lookup_rtti_type): Deal with struct symbol_in_block from lookup functions. * cp-support.h (cp_lookup_symbol_nonlocal, cp_lookup_symbol_from_namespace, cp_lookup_symbol_imports_or_template, cp_lookup_nested_symbol): Return struct symbol_in_block instead of mere symbols. * d-exp.y (d_type_from_name, d_module_from_name, push_variable, push_module_name): Deal with struct symbol_in_block from lookup functions. Remove uses of block_found. * eval.c (evaluate_subexp_standard): Update call to cp_lookup_symbol_namespace. * f-exp.y: Deal with struct symbol_in_block from lookup functions. Remove uses of block_found. (yylex): Likewise. * gdbtypes.c (lookup_typename, lookup_struct, lookup_union, lookup_enum, lookup_template_type, check_typedef): Deal with struct symbol_in_block from lookup functions. * guile/scm-frame.c (gdbscm_frame_read_var): Likewise. * guile/scm-symbol.c (gdbscm_lookup_symbol): Likewise. (gdbscm_lookup_global_symbol): Likewise. * gnu-v3-abi.c (gnuv3_get_typeid_type): Likewise. * go-exp.y: Likewise. Remove uses of block_found. (package_name_p, classify_packaged_name, classify_name): Likewise. * infrun.c (insert_exception_resume_breakpoint): Likewise. * jv-exp.y (push_variable): Likewise. * jv-lang.c (java_lookup_class, get_java_object_type): Likewise. * language.c (language_bool_type): Likewise. * language.h (struct language_defn): Update la_lookup_symbol_nonlocal to return a struct symbol_in_block rather than a mere symbol. * linespec.c (find_label_symbols): Deal with struct symbol_in_block from lookup functions. * m2-exp.y: Likewise. Remove uses of block_found. (yylex): Likewise. * mi/mi-cmd-stack.c (list_args_or_locals): Likewise. * objc-lang.c (lookup_struct_typedef, find_imps): Likewise. * p-exp.y: Likewise. Remove uses of block_found. (yylex): Likewise. * p-valprint.c (pascal_val_print): Likewise. * parse.c (write_dollar_variable): Likewise. Remove uses of block_found. * parser-defs.h (struct symtoken): Turn the SYM field into a struct symbol_in_block. * printcmd.c (address_info): Deal with struct symbol_in_block from lookup functions. * python/py-frame.c (frapy_read_var): Likewise. * python/py-symbol.c (gdbpy_lookup_symbol, gdbpy_lookup_global_symbol): Likewise. * skip.c (skip_function_command): Likewise. * solib-darwin.c (darwin_lookup_lib_symbol): Return a struct symbol_in_block instead of a mere symbol. * solib-spu.c (spu_lookup_lib_symbol): Likewise. * solib-svr4.c (elf_lookup_lib_symbol): Likewise. * solib.c (solib_global_lookup): Likewise. * solist.h (solib_global_lookup): Likewise. (struct target_so_ops): Update lookup_lib_global_symbol to return a struct symbol_in_block rather than a mere symbol. * source.c (select_source_symtab): Deal with struct symbol_in_block from lookup functions. * stack.c (print_frame_args, iterate_over_block_arg_vars): Likewise. * symfile.c (set_initial_language): Likewise. * symtab.c (SYMBOL_LOOKUP_FAILED): Turn into a struct symbol_in_block. (SYMBOL_LOOKUP_FAILED_P): New predicate as a macro. (struct symbol_cache_slot): Turn the FOUND field into a struct symbol_in_block. (block_found): Remove. (eq_symbol_entry): Update to deal with struct symbol_in_block in cache slots. (symbol_cache_lookup): Return a struct symbol_in_block rather than a mere symbol. (symbol_cache_mark_found): Add a BLOCK parameter to fill appropriately the cache slots. Update callers. (symbol_cache_dump): Update cache slots handling to the type change. (lookup_symbol_in_language, lookup_symbol, lookup_language_this, lookup_symbol_aux, lookup_local_symbol, lookup_symbol_in_objfile, lookup_global_symbol_from_objfile, lookup_symbol_in_objfile_symtabs, lookup_symbol_in_objfile_from_linkage_name, lookup_symbol_via_quick_fns, basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block, lookup_static_symbol, lookup_global_symbol): Return a struct symbol_in_block rather than a mere symbol. Deal with struct symbol_in_block from other lookup functions. Remove uses of block_found. (lookup_symbol_in_block): Remove uses of block_found. (struct global_sym_lookup_data): Turn the RESULT field into a struct symbol_in_block. (lookup_symbol_global_iterator_cb): Update references to the RESULT field. (search_symbols): Deal with struct symbol_in_block from lookup functions. * symtab.h (struct symbol_in_block): New structure. (block_found): Remove. (lookup_symbol_in_language, lookup_symbol, basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block, looku_static_symbol, lookup_global_symbol, lookup_symbol_in_block, lookup_language_this, lookup_global_symbol_from_objfile): Return a struct symbol_in_block rather than just a mere symbol. Update comments to remove mentions of block_found. * valops.c (find_function_in_inferior, value_struct_elt_for_reference, value_maybe_namespace_elt, value_of_this): Deal with struct symbol_in_block from lookup functions. * value.c (value_static_field, value_fn_field): Likewise.
2015-07-21 17:02:15 +02:00
else if (SYMBOL_CLASS (sym_info.symbol) == LOC_TYPEDEF)
* ada-lang.h (ada_renaming_category): New enumerated type. (ada_lookup_encoded_symbol): Declare. (ada_parse_renaming): Declare. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete declarations. * ada-lang.c (ada_parse_renaming): New function to concentrate extraction of information from renaming symbols. (parse_old_style_renaming): New function to concentrate extraction of old-style (purely type-based) renaming information. (renaming_is_visible): Rename to... (old_renaming_is_invisible): Rename and change sense of renaming_is_visible. (remove_out_of_scope_renamings): Rename to... (remove_irrelevant_renamings): Renames remove_out_of_scope_renamings and augments with additional logic to handle cases where the same object renaming is encoded both as a reference variable and an encoded renaming. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete definitions. (ada_lookup_encoded_symbol): New function factored out of ada_lookup_symbol. (ada_lookup_symbol): Reimplement to call ada_lookup_encoded_symbol. (wild_match): Don't reject perfect match of prefix. (ada_find_renaming_symbol): Factor old-style renaming logic into find_old_style_renaming_symbol. (find_old_style_renaming_symbol): New name for content of old ada_find_renaming_symbol. (ada_prefer_type): Reimplement not to use ada_renaming_type. * ada-exp.y (write_object_renaming): Change interface. Reimplement to use new arguments and ada_parse_renaming. Correct blocks used to find array index. (write_var_or_type): Reimplement to use ada_parse_renaming.
2007-12-21 12:50:11 +01:00
/* We have a renaming of an old-style renaming symbol. Don't
trust the block information. */
sym_info.block = orig_left_context;
* ada-lang.h (ada_renaming_category): New enumerated type. (ada_lookup_encoded_symbol): Declare. (ada_parse_renaming): Declare. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete declarations. * ada-lang.c (ada_parse_renaming): New function to concentrate extraction of information from renaming symbols. (parse_old_style_renaming): New function to concentrate extraction of old-style (purely type-based) renaming information. (renaming_is_visible): Rename to... (old_renaming_is_invisible): Rename and change sense of renaming_is_visible. (remove_out_of_scope_renamings): Rename to... (remove_irrelevant_renamings): Renames remove_out_of_scope_renamings and augments with additional logic to handle cases where the same object renaming is encoded both as a reference variable and an encoded renaming. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete definitions. (ada_lookup_encoded_symbol): New function factored out of ada_lookup_symbol. (ada_lookup_symbol): Reimplement to call ada_lookup_encoded_symbol. (wild_match): Don't reject perfect match of prefix. (ada_find_renaming_symbol): Factor old-style renaming logic into find_old_style_renaming_symbol. (find_old_style_renaming_symbol): New name for content of old ada_find_renaming_symbol. (ada_prefer_type): Reimplement not to use ada_renaming_type. * ada-exp.y (write_object_renaming): Change interface. Reimplement to use new arguments and ada_parse_renaming. Correct blocks used to find array index. (write_var_or_type): Reimplement to use ada_parse_renaming.
2007-12-21 12:50:11 +01:00
{
const char *inner_renamed_entity;
int inner_renamed_entity_len;
const char *inner_renaming_expr;
Replace the block_found global with explicit data-flow As Pedro suggested on gdb-patches@ (see https://sourceware.org/ml/gdb-patches/2015-05/msg00714.html), this change makes symbol lookup functions return a structure that includes both the symbol found and the block in which it was found. This makes it possible to get rid of the block_found global variable and thus makes block hunting explicit. gdb/ * ada-exp.y (write_object_renaming): Replace struct ada_symbol_info with struct block_symbol. Update field references accordingly. (block_lookup, select_possible_type_sym): Likewise. (find_primitive_type): Likewise. Also update call to ada_lookup_symbol to extract the symbol itself. (write_var_or_type, write_name_assoc): Likewise. * ada-lang.h (struct ada_symbol_info): Remove. (ada_lookup_symbol_list): Replace struct ada_symbol_info with struct block_symbol. (ada_lookup_encoded_symbol, user_select_syms): Likewise. (ada_lookup_symbol): Return struct block_symbol instead of a mere symbol. * ada-lang.c (defns_collected): Replace struct ada_symbol_info with struct block_symbol. (resolve_subexp, ada_resolve_function, sort_choices, user_select_syms, is_nonfunction, add_defn_to_vec, num_defns_collected, defns_collected, symbols_are_identical_enums, remove_extra_symbols, remove_irrelevant_renamings, add_lookup_symbol_list_worker, ada_lookup_symbol_list, ada_iterate_over_symbols, ada_lookup_encoded_symbol, get_var_value): Likewise. (ada_lookup_symbol): Return a block_symbol instead of a mere symbol. Replace struct ada_symbol_info with struct block_symbol. (ada_lookup_symbol_nonlocal): Likewise. (standard_lookup): Make block passing explicit through lookup_symbol_in_language. * ada-tasks.c (get_tcb_types_info): Update the calls to lookup_symbol_in_language to extract the mere symbol out of the returned value. (ada_tasks_inferior_data_sniffer): Likewise. * ax-gdb.c (gen_static_field): Likewise for the call to lookup_symbol. (gen_maybe_namespace_elt): Deal with struct symbol_in_block from lookup functions. (gen_expr): Likewise. * c-exp.y: Likewise. Remove uses of block_found. (lex_one_token, classify_inner_name, c_print_token): Likewise. (classify_name): Likewise. Rename the "sym" local variable to "bsym". * c-valprint.c (print_unpacked_pointer): Likewise. * compile/compile-c-symbols.c (convert_symbol_sym): Promote the "sym" parameter from struct symbol * to struct block_symbol. Use it to remove uses of block_found. Deal with struct symbol_in_block from lookup functions. (gcc_convert_symbol): Likewise. Update the call to convert_symbol_sym. * compile/compile-object-load.c (compile_object_load): Deal with struct symbol_in_block from lookup functions. * cp-namespace.c (cp_lookup_nested_symbol_1, cp_lookup_nested_symbol, cp_lookup_bare_symbol, cp_search_static_and_baseclasses, cp_lookup_symbol_in_namespace, cp_lookup_symbol_via_imports, cp_lookup_symbol_imports_or_template, cp_lookup_symbol_via_all_imports, cp_lookup_symbol_namespace, lookup_namespace_scope, cp_lookup_nonlocal, find_symbol_in_baseclass): Return struct symbol_in_block instead of mere symbols and deal with struct symbol_in_block from lookup functions. * cp-support.c (inspect_type, replace_typedefs, cp_lookup_rtti_type): Deal with struct symbol_in_block from lookup functions. * cp-support.h (cp_lookup_symbol_nonlocal, cp_lookup_symbol_from_namespace, cp_lookup_symbol_imports_or_template, cp_lookup_nested_symbol): Return struct symbol_in_block instead of mere symbols. * d-exp.y (d_type_from_name, d_module_from_name, push_variable, push_module_name): Deal with struct symbol_in_block from lookup functions. Remove uses of block_found. * eval.c (evaluate_subexp_standard): Update call to cp_lookup_symbol_namespace. * f-exp.y: Deal with struct symbol_in_block from lookup functions. Remove uses of block_found. (yylex): Likewise. * gdbtypes.c (lookup_typename, lookup_struct, lookup_union, lookup_enum, lookup_template_type, check_typedef): Deal with struct symbol_in_block from lookup functions. * guile/scm-frame.c (gdbscm_frame_read_var): Likewise. * guile/scm-symbol.c (gdbscm_lookup_symbol): Likewise. (gdbscm_lookup_global_symbol): Likewise. * gnu-v3-abi.c (gnuv3_get_typeid_type): Likewise. * go-exp.y: Likewise. Remove uses of block_found. (package_name_p, classify_packaged_name, classify_name): Likewise. * infrun.c (insert_exception_resume_breakpoint): Likewise. * jv-exp.y (push_variable): Likewise. * jv-lang.c (java_lookup_class, get_java_object_type): Likewise. * language.c (language_bool_type): Likewise. * language.h (struct language_defn): Update la_lookup_symbol_nonlocal to return a struct symbol_in_block rather than a mere symbol. * linespec.c (find_label_symbols): Deal with struct symbol_in_block from lookup functions. * m2-exp.y: Likewise. Remove uses of block_found. (yylex): Likewise. * mi/mi-cmd-stack.c (list_args_or_locals): Likewise. * objc-lang.c (lookup_struct_typedef, find_imps): Likewise. * p-exp.y: Likewise. Remove uses of block_found. (yylex): Likewise. * p-valprint.c (pascal_val_print): Likewise. * parse.c (write_dollar_variable): Likewise. Remove uses of block_found. * parser-defs.h (struct symtoken): Turn the SYM field into a struct symbol_in_block. * printcmd.c (address_info): Deal with struct symbol_in_block from lookup functions. * python/py-frame.c (frapy_read_var): Likewise. * python/py-symbol.c (gdbpy_lookup_symbol, gdbpy_lookup_global_symbol): Likewise. * skip.c (skip_function_command): Likewise. * solib-darwin.c (darwin_lookup_lib_symbol): Return a struct symbol_in_block instead of a mere symbol. * solib-spu.c (spu_lookup_lib_symbol): Likewise. * solib-svr4.c (elf_lookup_lib_symbol): Likewise. * solib.c (solib_global_lookup): Likewise. * solist.h (solib_global_lookup): Likewise. (struct target_so_ops): Update lookup_lib_global_symbol to return a struct symbol_in_block rather than a mere symbol. * source.c (select_source_symtab): Deal with struct symbol_in_block from lookup functions. * stack.c (print_frame_args, iterate_over_block_arg_vars): Likewise. * symfile.c (set_initial_language): Likewise. * symtab.c (SYMBOL_LOOKUP_FAILED): Turn into a struct symbol_in_block. (SYMBOL_LOOKUP_FAILED_P): New predicate as a macro. (struct symbol_cache_slot): Turn the FOUND field into a struct symbol_in_block. (block_found): Remove. (eq_symbol_entry): Update to deal with struct symbol_in_block in cache slots. (symbol_cache_lookup): Return a struct symbol_in_block rather than a mere symbol. (symbol_cache_mark_found): Add a BLOCK parameter to fill appropriately the cache slots. Update callers. (symbol_cache_dump): Update cache slots handling to the type change. (lookup_symbol_in_language, lookup_symbol, lookup_language_this, lookup_symbol_aux, lookup_local_symbol, lookup_symbol_in_objfile, lookup_global_symbol_from_objfile, lookup_symbol_in_objfile_symtabs, lookup_symbol_in_objfile_from_linkage_name, lookup_symbol_via_quick_fns, basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block, lookup_static_symbol, lookup_global_symbol): Return a struct symbol_in_block rather than a mere symbol. Deal with struct symbol_in_block from other lookup functions. Remove uses of block_found. (lookup_symbol_in_block): Remove uses of block_found. (struct global_sym_lookup_data): Turn the RESULT field into a struct symbol_in_block. (lookup_symbol_global_iterator_cb): Update references to the RESULT field. (search_symbols): Deal with struct symbol_in_block from lookup functions. * symtab.h (struct symbol_in_block): New structure. (block_found): Remove. (lookup_symbol_in_language, lookup_symbol, basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block, looku_static_symbol, lookup_global_symbol, lookup_symbol_in_block, lookup_language_this, lookup_global_symbol_from_objfile): Return a struct symbol_in_block rather than just a mere symbol. Update comments to remove mentions of block_found. * valops.c (find_function_in_inferior, value_struct_elt_for_reference, value_maybe_namespace_elt, value_of_this): Deal with struct symbol_in_block from lookup functions. * value.c (value_static_field, value_fn_field): Likewise.
2015-07-21 17:02:15 +02:00
switch (ada_parse_renaming (sym_info.symbol, &inner_renamed_entity,
* ada-lang.h (ada_renaming_category): New enumerated type. (ada_lookup_encoded_symbol): Declare. (ada_parse_renaming): Declare. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete declarations. * ada-lang.c (ada_parse_renaming): New function to concentrate extraction of information from renaming symbols. (parse_old_style_renaming): New function to concentrate extraction of old-style (purely type-based) renaming information. (renaming_is_visible): Rename to... (old_renaming_is_invisible): Rename and change sense of renaming_is_visible. (remove_out_of_scope_renamings): Rename to... (remove_irrelevant_renamings): Renames remove_out_of_scope_renamings and augments with additional logic to handle cases where the same object renaming is encoded both as a reference variable and an encoded renaming. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete definitions. (ada_lookup_encoded_symbol): New function factored out of ada_lookup_symbol. (ada_lookup_symbol): Reimplement to call ada_lookup_encoded_symbol. (wild_match): Don't reject perfect match of prefix. (ada_find_renaming_symbol): Factor old-style renaming logic into find_old_style_renaming_symbol. (find_old_style_renaming_symbol): New name for content of old ada_find_renaming_symbol. (ada_prefer_type): Reimplement not to use ada_renaming_type. * ada-exp.y (write_object_renaming): Change interface. Reimplement to use new arguments and ada_parse_renaming. Correct blocks used to find array index. (write_var_or_type): Reimplement to use ada_parse_renaming.
2007-12-21 12:50:11 +01:00
&inner_renamed_entity_len,
&inner_renaming_expr))
{
case ADA_NOT_RENAMING:
local variable watchpoint not deleted after leaving scope When debugging an Ada program, and inserting a watchpoint tracking a local variable, the watchpoint doesn't get automatically deleted upon leaving that variable's scope. This watchpoint then starts creating problems later on, when trying to resume the program's execution from a location outside of the watchpoint's scope: (gdb) c Continuing. Breakpoint 2, foo_p708_025 () at foo_p708_025.adb:7 7 Do_Nothing (Val); (gdb) n No frame is currently executing in block pck.get_val. Command aborted. (gdb) c Continuing. No frame is currently executing in block pck.get_val. Command aborted. The expected output is the following: - The program's execution after the first continue should stop as soon as we reach the end of the watchpoint's scope, and the debugger should be deleting it. - Then we can continue until reaching breakpoint 2 above; - After which we should be able to do next/continue as usual. The reason the watchpoint is not automatically deleted at scope exit is because the watchpoint is not marked as being scope-specific (b->exp_valid_block is equal NULL), and this is because the symbol lookup for our local variable failed to set the innermost_block global variable during the lookup. More precisely, if we look at watch_command_1, we do the following: innermost_block = NULL; [...] exp = parse_exp_1 (&arg, 0, 0, 0); [...] exp_valid_block = innermost_block; Currently, innermost_block stays NULL after the call to parse_exp_1. Digging further, this innermost_block is typically set during symbol lookup when the symbol is considered to have a frame-relative address. For instance, in c-exp.y, we see some code like the following: if (symbol_read_needs_frame (sym.symbol)) { if (innermost_block == 0 || contained_in (sym.block, innermost_block)) innermost_block = sym.block; } We actually have the exact same mechanism in ada-exp.y, except that it vhas accidently been turned off. See write_var_from_sym, where we start with: if (orig_left_context == NULL && symbol_read_needs_frame (sym)) { if (innermost_block == 0 || contained_in (block, innermost_block)) innermost_block = block; } In this case, orig_left_context is a parameter, and looking at the point of call in write_var_or_type, we see: if (nsyms == 1) { write_var_from_sym (par_state, block, syms[0].block, syms[0].symbol); In the call above, the paramater we are interested in is "block", which is a parameter for write_var_or_type as well, except we explicitly override its value at the beginning when found to be NULL: if (block == NULL) block = expression_context_block; So the block we pass to write_var_from_sym is not NULL, and we therefore don't set innermost_block, which leads to the watchpoint no longer being marked as scope-specific. The handling of orig_left_context in write_var_from_sym was there to handle the case where a user writes an expression where the symbol is qualified with a scope (Eg: "function::variable"). But it appears that handling this is specifically here is no longer necessary, so this patch simply removes that parameter and the associated check, and then updates all the points of calls. Interestingly, this also affects GDB/MI, and in particular varobjs, because local variables are now properly reported as having a block, which causes the associated varob to have a "thread-id" field. This patch also adjusts a couple of Ada/gdb-mi tests. gdb/ChangeLog: * ada-exp.y (write_var_from_sym): Remove parameter "orig_left_context". Update all callers. gdb/testsuite/ChangeLog: * gdb.ada/scoped_watch: New testcase. * gdb.ada/watch_arg.exp: Adjust expected behavior to the behavior which is actually correct. * gdb.ada/mi_interface.exp: Add missing thread-id in expected varobj. * gdb.ada/mi_var_array.exp: Add missing thread-id in expected varobj.
2017-03-03 17:31:13 +01:00
write_var_from_sym (par_state, sym_info.block, sym_info.symbol);
* ada-lang.h (ada_renaming_category): New enumerated type. (ada_lookup_encoded_symbol): Declare. (ada_parse_renaming): Declare. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete declarations. * ada-lang.c (ada_parse_renaming): New function to concentrate extraction of information from renaming symbols. (parse_old_style_renaming): New function to concentrate extraction of old-style (purely type-based) renaming information. (renaming_is_visible): Rename to... (old_renaming_is_invisible): Rename and change sense of renaming_is_visible. (remove_out_of_scope_renamings): Rename to... (remove_irrelevant_renamings): Renames remove_out_of_scope_renamings and augments with additional logic to handle cases where the same object renaming is encoded both as a reference variable and an encoded renaming. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete definitions. (ada_lookup_encoded_symbol): New function factored out of ada_lookup_symbol. (ada_lookup_symbol): Reimplement to call ada_lookup_encoded_symbol. (wild_match): Don't reject perfect match of prefix. (ada_find_renaming_symbol): Factor old-style renaming logic into find_old_style_renaming_symbol. (find_old_style_renaming_symbol): New name for content of old ada_find_renaming_symbol. (ada_prefer_type): Reimplement not to use ada_renaming_type. * ada-exp.y (write_object_renaming): Change interface. Reimplement to use new arguments and ada_parse_renaming. Correct blocks used to find array index. (write_var_or_type): Reimplement to use ada_parse_renaming.
2007-12-21 12:50:11 +01:00
break;
case ADA_OBJECT_RENAMING:
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_object_renaming (par_state, sym_info.block,
* ada-lang.h (ada_renaming_category): New enumerated type. (ada_lookup_encoded_symbol): Declare. (ada_parse_renaming): Declare. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete declarations. * ada-lang.c (ada_parse_renaming): New function to concentrate extraction of information from renaming symbols. (parse_old_style_renaming): New function to concentrate extraction of old-style (purely type-based) renaming information. (renaming_is_visible): Rename to... (old_renaming_is_invisible): Rename and change sense of renaming_is_visible. (remove_out_of_scope_renamings): Rename to... (remove_irrelevant_renamings): Renames remove_out_of_scope_renamings and augments with additional logic to handle cases where the same object renaming is encoded both as a reference variable and an encoded renaming. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete definitions. (ada_lookup_encoded_symbol): New function factored out of ada_lookup_symbol. (ada_lookup_symbol): Reimplement to call ada_lookup_encoded_symbol. (wild_match): Don't reject perfect match of prefix. (ada_find_renaming_symbol): Factor old-style renaming logic into find_old_style_renaming_symbol. (find_old_style_renaming_symbol): New name for content of old ada_find_renaming_symbol. (ada_prefer_type): Reimplement not to use ada_renaming_type. * ada-exp.y (write_object_renaming): Change interface. Reimplement to use new arguments and ada_parse_renaming. Correct blocks used to find array index. (write_var_or_type): Reimplement to use ada_parse_renaming.
2007-12-21 12:50:11 +01:00
inner_renamed_entity, inner_renamed_entity_len,
inner_renaming_expr, max_depth - 1);
break;
default:
goto BadEncoding;
}
}
2002-06-04 17:28:49 +02:00
slice_state = SIMPLE_INDEX;
* ada-lang.h (ada_renaming_category): New enumerated type. (ada_lookup_encoded_symbol): Declare. (ada_parse_renaming): Declare. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete declarations. * ada-lang.c (ada_parse_renaming): New function to concentrate extraction of information from renaming symbols. (parse_old_style_renaming): New function to concentrate extraction of old-style (purely type-based) renaming information. (renaming_is_visible): Rename to... (old_renaming_is_invisible): Rename and change sense of renaming_is_visible. (remove_out_of_scope_renamings): Rename to... (remove_irrelevant_renamings): Renames remove_out_of_scope_renamings and augments with additional logic to handle cases where the same object renaming is encoded both as a reference variable and an encoded renaming. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete definitions. (ada_lookup_encoded_symbol): New function factored out of ada_lookup_symbol. (ada_lookup_symbol): Reimplement to call ada_lookup_encoded_symbol. (wild_match): Don't reject perfect match of prefix. (ada_find_renaming_symbol): Factor old-style renaming logic into find_old_style_renaming_symbol. (find_old_style_renaming_symbol): New name for content of old ada_find_renaming_symbol. (ada_prefer_type): Reimplement not to use ada_renaming_type. * ada-exp.y (write_object_renaming): Change interface. Reimplement to use new arguments and ada_parse_renaming. Correct blocks used to find array index. (write_var_or_type): Reimplement to use ada_parse_renaming.
2007-12-21 12:50:11 +01:00
while (*renaming_expr == 'X')
2002-06-04 17:28:49 +02:00
{
* ada-lang.h (ada_renaming_category): New enumerated type. (ada_lookup_encoded_symbol): Declare. (ada_parse_renaming): Declare. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete declarations. * ada-lang.c (ada_parse_renaming): New function to concentrate extraction of information from renaming symbols. (parse_old_style_renaming): New function to concentrate extraction of old-style (purely type-based) renaming information. (renaming_is_visible): Rename to... (old_renaming_is_invisible): Rename and change sense of renaming_is_visible. (remove_out_of_scope_renamings): Rename to... (remove_irrelevant_renamings): Renames remove_out_of_scope_renamings and augments with additional logic to handle cases where the same object renaming is encoded both as a reference variable and an encoded renaming. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete definitions. (ada_lookup_encoded_symbol): New function factored out of ada_lookup_symbol. (ada_lookup_symbol): Reimplement to call ada_lookup_encoded_symbol. (wild_match): Don't reject perfect match of prefix. (ada_find_renaming_symbol): Factor old-style renaming logic into find_old_style_renaming_symbol. (find_old_style_renaming_symbol): New name for content of old ada_find_renaming_symbol. (ada_prefer_type): Reimplement not to use ada_renaming_type. * ada-exp.y (write_object_renaming): Change interface. Reimplement to use new arguments and ada_parse_renaming. Correct blocks used to find array index. (write_var_or_type): Reimplement to use ada_parse_renaming.
2007-12-21 12:50:11 +01:00
renaming_expr += 1;
2002-06-04 17:28:49 +02:00
* ada-lang.h (ada_renaming_category): New enumerated type. (ada_lookup_encoded_symbol): Declare. (ada_parse_renaming): Declare. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete declarations. * ada-lang.c (ada_parse_renaming): New function to concentrate extraction of information from renaming symbols. (parse_old_style_renaming): New function to concentrate extraction of old-style (purely type-based) renaming information. (renaming_is_visible): Rename to... (old_renaming_is_invisible): Rename and change sense of renaming_is_visible. (remove_out_of_scope_renamings): Rename to... (remove_irrelevant_renamings): Renames remove_out_of_scope_renamings and augments with additional logic to handle cases where the same object renaming is encoded both as a reference variable and an encoded renaming. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete definitions. (ada_lookup_encoded_symbol): New function factored out of ada_lookup_symbol. (ada_lookup_symbol): Reimplement to call ada_lookup_encoded_symbol. (wild_match): Don't reject perfect match of prefix. (ada_find_renaming_symbol): Factor old-style renaming logic into find_old_style_renaming_symbol. (find_old_style_renaming_symbol): New name for content of old ada_find_renaming_symbol. (ada_prefer_type): Reimplement not to use ada_renaming_type. * ada-exp.y (write_object_renaming): Change interface. Reimplement to use new arguments and ada_parse_renaming. Correct blocks used to find array index. (write_var_or_type): Reimplement to use ada_parse_renaming.
2007-12-21 12:50:11 +01:00
switch (*renaming_expr) {
case 'A':
* ada-lang.h (ada_renaming_category): New enumerated type. (ada_lookup_encoded_symbol): Declare. (ada_parse_renaming): Declare. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete declarations. * ada-lang.c (ada_parse_renaming): New function to concentrate extraction of information from renaming symbols. (parse_old_style_renaming): New function to concentrate extraction of old-style (purely type-based) renaming information. (renaming_is_visible): Rename to... (old_renaming_is_invisible): Rename and change sense of renaming_is_visible. (remove_out_of_scope_renamings): Rename to... (remove_irrelevant_renamings): Renames remove_out_of_scope_renamings and augments with additional logic to handle cases where the same object renaming is encoded both as a reference variable and an encoded renaming. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete definitions. (ada_lookup_encoded_symbol): New function factored out of ada_lookup_symbol. (ada_lookup_symbol): Reimplement to call ada_lookup_encoded_symbol. (wild_match): Don't reject perfect match of prefix. (ada_find_renaming_symbol): Factor old-style renaming logic into find_old_style_renaming_symbol. (find_old_style_renaming_symbol): New name for content of old ada_find_renaming_symbol. (ada_prefer_type): Reimplement not to use ada_renaming_type. * ada-exp.y (write_object_renaming): Change interface. Reimplement to use new arguments and ada_parse_renaming. Correct blocks used to find array index. (write_var_or_type): Reimplement to use ada_parse_renaming.
2007-12-21 12:50:11 +01:00
renaming_expr += 1;
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_exp_elt_opcode (par_state, UNOP_IND);
break;
2002-06-04 17:28:49 +02:00
case 'L':
slice_state = LOWER_BOUND;
/* FALLTHROUGH */
2002-06-04 17:28:49 +02:00
case 'S':
* ada-lang.h (ada_renaming_category): New enumerated type. (ada_lookup_encoded_symbol): Declare. (ada_parse_renaming): Declare. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete declarations. * ada-lang.c (ada_parse_renaming): New function to concentrate extraction of information from renaming symbols. (parse_old_style_renaming): New function to concentrate extraction of old-style (purely type-based) renaming information. (renaming_is_visible): Rename to... (old_renaming_is_invisible): Rename and change sense of renaming_is_visible. (remove_out_of_scope_renamings): Rename to... (remove_irrelevant_renamings): Renames remove_out_of_scope_renamings and augments with additional logic to handle cases where the same object renaming is encoded both as a reference variable and an encoded renaming. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete definitions. (ada_lookup_encoded_symbol): New function factored out of ada_lookup_symbol. (ada_lookup_symbol): Reimplement to call ada_lookup_encoded_symbol. (wild_match): Don't reject perfect match of prefix. (ada_find_renaming_symbol): Factor old-style renaming logic into find_old_style_renaming_symbol. (find_old_style_renaming_symbol): New name for content of old ada_find_renaming_symbol. (ada_prefer_type): Reimplement not to use ada_renaming_type. * ada-exp.y (write_object_renaming): Change interface. Reimplement to use new arguments and ada_parse_renaming. Correct blocks used to find array index. (write_var_or_type): Reimplement to use ada_parse_renaming.
2007-12-21 12:50:11 +01:00
renaming_expr += 1;
if (isdigit (*renaming_expr))
2002-06-04 17:28:49 +02:00
{
char *next;
* ada-lang.h (ada_renaming_category): New enumerated type. (ada_lookup_encoded_symbol): Declare. (ada_parse_renaming): Declare. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete declarations. * ada-lang.c (ada_parse_renaming): New function to concentrate extraction of information from renaming symbols. (parse_old_style_renaming): New function to concentrate extraction of old-style (purely type-based) renaming information. (renaming_is_visible): Rename to... (old_renaming_is_invisible): Rename and change sense of renaming_is_visible. (remove_out_of_scope_renamings): Rename to... (remove_irrelevant_renamings): Renames remove_out_of_scope_renamings and augments with additional logic to handle cases where the same object renaming is encoded both as a reference variable and an encoded renaming. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete definitions. (ada_lookup_encoded_symbol): New function factored out of ada_lookup_symbol. (ada_lookup_symbol): Reimplement to call ada_lookup_encoded_symbol. (wild_match): Don't reject perfect match of prefix. (ada_find_renaming_symbol): Factor old-style renaming logic into find_old_style_renaming_symbol. (find_old_style_renaming_symbol): New name for content of old ada_find_renaming_symbol. (ada_prefer_type): Reimplement not to use ada_renaming_type. * ada-exp.y (write_object_renaming): Change interface. Reimplement to use new arguments and ada_parse_renaming. Correct blocks used to find array index. (write_var_or_type): Reimplement to use ada_parse_renaming.
2007-12-21 12:50:11 +01:00
long val = strtol (renaming_expr, &next, 10);
if (next == renaming_expr)
2002-06-04 17:28:49 +02:00
goto BadEncoding;
* ada-lang.h (ada_renaming_category): New enumerated type. (ada_lookup_encoded_symbol): Declare. (ada_parse_renaming): Declare. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete declarations. * ada-lang.c (ada_parse_renaming): New function to concentrate extraction of information from renaming symbols. (parse_old_style_renaming): New function to concentrate extraction of old-style (purely type-based) renaming information. (renaming_is_visible): Rename to... (old_renaming_is_invisible): Rename and change sense of renaming_is_visible. (remove_out_of_scope_renamings): Rename to... (remove_irrelevant_renamings): Renames remove_out_of_scope_renamings and augments with additional logic to handle cases where the same object renaming is encoded both as a reference variable and an encoded renaming. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete definitions. (ada_lookup_encoded_symbol): New function factored out of ada_lookup_symbol. (ada_lookup_symbol): Reimplement to call ada_lookup_encoded_symbol. (wild_match): Don't reject perfect match of prefix. (ada_find_renaming_symbol): Factor old-style renaming logic into find_old_style_renaming_symbol. (find_old_style_renaming_symbol): New name for content of old ada_find_renaming_symbol. (ada_prefer_type): Reimplement not to use ada_renaming_type. * ada-exp.y (write_object_renaming): Change interface. Reimplement to use new arguments and ada_parse_renaming. Correct blocks used to find array index. (write_var_or_type): Reimplement to use ada_parse_renaming.
2007-12-21 12:50:11 +01:00
renaming_expr = next;
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_exp_elt_opcode (par_state, OP_LONG);
write_exp_elt_type (par_state, type_int (par_state));
write_exp_elt_longcst (par_state, (LONGEST) val);
write_exp_elt_opcode (par_state, OP_LONG);
}
2002-06-04 17:28:49 +02:00
else
{
const char *end;
char *index_name;
Replace the block_found global with explicit data-flow As Pedro suggested on gdb-patches@ (see https://sourceware.org/ml/gdb-patches/2015-05/msg00714.html), this change makes symbol lookup functions return a structure that includes both the symbol found and the block in which it was found. This makes it possible to get rid of the block_found global variable and thus makes block hunting explicit. gdb/ * ada-exp.y (write_object_renaming): Replace struct ada_symbol_info with struct block_symbol. Update field references accordingly. (block_lookup, select_possible_type_sym): Likewise. (find_primitive_type): Likewise. Also update call to ada_lookup_symbol to extract the symbol itself. (write_var_or_type, write_name_assoc): Likewise. * ada-lang.h (struct ada_symbol_info): Remove. (ada_lookup_symbol_list): Replace struct ada_symbol_info with struct block_symbol. (ada_lookup_encoded_symbol, user_select_syms): Likewise. (ada_lookup_symbol): Return struct block_symbol instead of a mere symbol. * ada-lang.c (defns_collected): Replace struct ada_symbol_info with struct block_symbol. (resolve_subexp, ada_resolve_function, sort_choices, user_select_syms, is_nonfunction, add_defn_to_vec, num_defns_collected, defns_collected, symbols_are_identical_enums, remove_extra_symbols, remove_irrelevant_renamings, add_lookup_symbol_list_worker, ada_lookup_symbol_list, ada_iterate_over_symbols, ada_lookup_encoded_symbol, get_var_value): Likewise. (ada_lookup_symbol): Return a block_symbol instead of a mere symbol. Replace struct ada_symbol_info with struct block_symbol. (ada_lookup_symbol_nonlocal): Likewise. (standard_lookup): Make block passing explicit through lookup_symbol_in_language. * ada-tasks.c (get_tcb_types_info): Update the calls to lookup_symbol_in_language to extract the mere symbol out of the returned value. (ada_tasks_inferior_data_sniffer): Likewise. * ax-gdb.c (gen_static_field): Likewise for the call to lookup_symbol. (gen_maybe_namespace_elt): Deal with struct symbol_in_block from lookup functions. (gen_expr): Likewise. * c-exp.y: Likewise. Remove uses of block_found. (lex_one_token, classify_inner_name, c_print_token): Likewise. (classify_name): Likewise. Rename the "sym" local variable to "bsym". * c-valprint.c (print_unpacked_pointer): Likewise. * compile/compile-c-symbols.c (convert_symbol_sym): Promote the "sym" parameter from struct symbol * to struct block_symbol. Use it to remove uses of block_found. Deal with struct symbol_in_block from lookup functions. (gcc_convert_symbol): Likewise. Update the call to convert_symbol_sym. * compile/compile-object-load.c (compile_object_load): Deal with struct symbol_in_block from lookup functions. * cp-namespace.c (cp_lookup_nested_symbol_1, cp_lookup_nested_symbol, cp_lookup_bare_symbol, cp_search_static_and_baseclasses, cp_lookup_symbol_in_namespace, cp_lookup_symbol_via_imports, cp_lookup_symbol_imports_or_template, cp_lookup_symbol_via_all_imports, cp_lookup_symbol_namespace, lookup_namespace_scope, cp_lookup_nonlocal, find_symbol_in_baseclass): Return struct symbol_in_block instead of mere symbols and deal with struct symbol_in_block from lookup functions. * cp-support.c (inspect_type, replace_typedefs, cp_lookup_rtti_type): Deal with struct symbol_in_block from lookup functions. * cp-support.h (cp_lookup_symbol_nonlocal, cp_lookup_symbol_from_namespace, cp_lookup_symbol_imports_or_template, cp_lookup_nested_symbol): Return struct symbol_in_block instead of mere symbols. * d-exp.y (d_type_from_name, d_module_from_name, push_variable, push_module_name): Deal with struct symbol_in_block from lookup functions. Remove uses of block_found. * eval.c (evaluate_subexp_standard): Update call to cp_lookup_symbol_namespace. * f-exp.y: Deal with struct symbol_in_block from lookup functions. Remove uses of block_found. (yylex): Likewise. * gdbtypes.c (lookup_typename, lookup_struct, lookup_union, lookup_enum, lookup_template_type, check_typedef): Deal with struct symbol_in_block from lookup functions. * guile/scm-frame.c (gdbscm_frame_read_var): Likewise. * guile/scm-symbol.c (gdbscm_lookup_symbol): Likewise. (gdbscm_lookup_global_symbol): Likewise. * gnu-v3-abi.c (gnuv3_get_typeid_type): Likewise. * go-exp.y: Likewise. Remove uses of block_found. (package_name_p, classify_packaged_name, classify_name): Likewise. * infrun.c (insert_exception_resume_breakpoint): Likewise. * jv-exp.y (push_variable): Likewise. * jv-lang.c (java_lookup_class, get_java_object_type): Likewise. * language.c (language_bool_type): Likewise. * language.h (struct language_defn): Update la_lookup_symbol_nonlocal to return a struct symbol_in_block rather than a mere symbol. * linespec.c (find_label_symbols): Deal with struct symbol_in_block from lookup functions. * m2-exp.y: Likewise. Remove uses of block_found. (yylex): Likewise. * mi/mi-cmd-stack.c (list_args_or_locals): Likewise. * objc-lang.c (lookup_struct_typedef, find_imps): Likewise. * p-exp.y: Likewise. Remove uses of block_found. (yylex): Likewise. * p-valprint.c (pascal_val_print): Likewise. * parse.c (write_dollar_variable): Likewise. Remove uses of block_found. * parser-defs.h (struct symtoken): Turn the SYM field into a struct symbol_in_block. * printcmd.c (address_info): Deal with struct symbol_in_block from lookup functions. * python/py-frame.c (frapy_read_var): Likewise. * python/py-symbol.c (gdbpy_lookup_symbol, gdbpy_lookup_global_symbol): Likewise. * skip.c (skip_function_command): Likewise. * solib-darwin.c (darwin_lookup_lib_symbol): Return a struct symbol_in_block instead of a mere symbol. * solib-spu.c (spu_lookup_lib_symbol): Likewise. * solib-svr4.c (elf_lookup_lib_symbol): Likewise. * solib.c (solib_global_lookup): Likewise. * solist.h (solib_global_lookup): Likewise. (struct target_so_ops): Update lookup_lib_global_symbol to return a struct symbol_in_block rather than a mere symbol. * source.c (select_source_symtab): Deal with struct symbol_in_block from lookup functions. * stack.c (print_frame_args, iterate_over_block_arg_vars): Likewise. * symfile.c (set_initial_language): Likewise. * symtab.c (SYMBOL_LOOKUP_FAILED): Turn into a struct symbol_in_block. (SYMBOL_LOOKUP_FAILED_P): New predicate as a macro. (struct symbol_cache_slot): Turn the FOUND field into a struct symbol_in_block. (block_found): Remove. (eq_symbol_entry): Update to deal with struct symbol_in_block in cache slots. (symbol_cache_lookup): Return a struct symbol_in_block rather than a mere symbol. (symbol_cache_mark_found): Add a BLOCK parameter to fill appropriately the cache slots. Update callers. (symbol_cache_dump): Update cache slots handling to the type change. (lookup_symbol_in_language, lookup_symbol, lookup_language_this, lookup_symbol_aux, lookup_local_symbol, lookup_symbol_in_objfile, lookup_global_symbol_from_objfile, lookup_symbol_in_objfile_symtabs, lookup_symbol_in_objfile_from_linkage_name, lookup_symbol_via_quick_fns, basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block, lookup_static_symbol, lookup_global_symbol): Return a struct symbol_in_block rather than a mere symbol. Deal with struct symbol_in_block from other lookup functions. Remove uses of block_found. (lookup_symbol_in_block): Remove uses of block_found. (struct global_sym_lookup_data): Turn the RESULT field into a struct symbol_in_block. (lookup_symbol_global_iterator_cb): Update references to the RESULT field. (search_symbols): Deal with struct symbol_in_block from lookup functions. * symtab.h (struct symbol_in_block): New structure. (block_found): Remove. (lookup_symbol_in_language, lookup_symbol, basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block, looku_static_symbol, lookup_global_symbol, lookup_symbol_in_block, lookup_language_this, lookup_global_symbol_from_objfile): Return a struct symbol_in_block rather than just a mere symbol. Update comments to remove mentions of block_found. * valops.c (find_function_in_inferior, value_struct_elt_for_reference, value_maybe_namespace_elt, value_of_this): Deal with struct symbol_in_block from lookup functions. * value.c (value_static_field, value_fn_field): Likewise.
2015-07-21 17:02:15 +02:00
struct block_symbol index_sym_info;
2002-06-04 17:28:49 +02:00
* ada-lang.h (ada_renaming_category): New enumerated type. (ada_lookup_encoded_symbol): Declare. (ada_parse_renaming): Declare. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete declarations. * ada-lang.c (ada_parse_renaming): New function to concentrate extraction of information from renaming symbols. (parse_old_style_renaming): New function to concentrate extraction of old-style (purely type-based) renaming information. (renaming_is_visible): Rename to... (old_renaming_is_invisible): Rename and change sense of renaming_is_visible. (remove_out_of_scope_renamings): Rename to... (remove_irrelevant_renamings): Renames remove_out_of_scope_renamings and augments with additional logic to handle cases where the same object renaming is encoded both as a reference variable and an encoded renaming. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete definitions. (ada_lookup_encoded_symbol): New function factored out of ada_lookup_symbol. (ada_lookup_symbol): Reimplement to call ada_lookup_encoded_symbol. (wild_match): Don't reject perfect match of prefix. (ada_find_renaming_symbol): Factor old-style renaming logic into find_old_style_renaming_symbol. (find_old_style_renaming_symbol): New name for content of old ada_find_renaming_symbol. (ada_prefer_type): Reimplement not to use ada_renaming_type. * ada-exp.y (write_object_renaming): Change interface. Reimplement to use new arguments and ada_parse_renaming. Correct blocks used to find array index. (write_var_or_type): Reimplement to use ada_parse_renaming.
2007-12-21 12:50:11 +01:00
end = strchr (renaming_expr, 'X');
if (end == NULL)
* ada-lang.h (ada_renaming_category): New enumerated type. (ada_lookup_encoded_symbol): Declare. (ada_parse_renaming): Declare. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete declarations. * ada-lang.c (ada_parse_renaming): New function to concentrate extraction of information from renaming symbols. (parse_old_style_renaming): New function to concentrate extraction of old-style (purely type-based) renaming information. (renaming_is_visible): Rename to... (old_renaming_is_invisible): Rename and change sense of renaming_is_visible. (remove_out_of_scope_renamings): Rename to... (remove_irrelevant_renamings): Renames remove_out_of_scope_renamings and augments with additional logic to handle cases where the same object renaming is encoded both as a reference variable and an encoded renaming. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete definitions. (ada_lookup_encoded_symbol): New function factored out of ada_lookup_symbol. (ada_lookup_symbol): Reimplement to call ada_lookup_encoded_symbol. (wild_match): Don't reject perfect match of prefix. (ada_find_renaming_symbol): Factor old-style renaming logic into find_old_style_renaming_symbol. (find_old_style_renaming_symbol): New name for content of old ada_find_renaming_symbol. (ada_prefer_type): Reimplement not to use ada_renaming_type. * ada-exp.y (write_object_renaming): Change interface. Reimplement to use new arguments and ada_parse_renaming. Correct blocks used to find array index. (write_var_or_type): Reimplement to use ada_parse_renaming.
2007-12-21 12:50:11 +01:00
end = renaming_expr + strlen (renaming_expr);
index_name = obstack_strndup (&temp_parse_space, renaming_expr,
end - renaming_expr);
* ada-lang.h (ada_renaming_category): New enumerated type. (ada_lookup_encoded_symbol): Declare. (ada_parse_renaming): Declare. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete declarations. * ada-lang.c (ada_parse_renaming): New function to concentrate extraction of information from renaming symbols. (parse_old_style_renaming): New function to concentrate extraction of old-style (purely type-based) renaming information. (renaming_is_visible): Rename to... (old_renaming_is_invisible): Rename and change sense of renaming_is_visible. (remove_out_of_scope_renamings): Rename to... (remove_irrelevant_renamings): Renames remove_out_of_scope_renamings and augments with additional logic to handle cases where the same object renaming is encoded both as a reference variable and an encoded renaming. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete definitions. (ada_lookup_encoded_symbol): New function factored out of ada_lookup_symbol. (ada_lookup_symbol): Reimplement to call ada_lookup_encoded_symbol. (wild_match): Don't reject perfect match of prefix. (ada_find_renaming_symbol): Factor old-style renaming logic into find_old_style_renaming_symbol. (find_old_style_renaming_symbol): New name for content of old ada_find_renaming_symbol. (ada_prefer_type): Reimplement not to use ada_renaming_type. * ada-exp.y (write_object_renaming): Change interface. Reimplement to use new arguments and ada_parse_renaming. Correct blocks used to find array index. (write_var_or_type): Reimplement to use ada_parse_renaming.
2007-12-21 12:50:11 +01:00
renaming_expr = end;
(Ada) problem printing renaming which references a subprogram parameter Consider the following code, which creates a local variable B which is a renaming whose expression references a subprogram parameter: procedure Flip (Bits : in out Bits_Type; I : Natural) is begin declare B : Boolean renames Bits (I); begin B := not B; -- BREAK end; end Flip; Trying to print the value of B when at the "BREAK" line currently does not work: (gdb) p b Could not find i What happens is the following: For the renaming, GNAT generates a variable whose name is encoded as follow: b___XR_bits___XEXSi GDB properly detects that variable, determines that, to compute the variable's value, we start from the symbol "Bits", which we then have to subscript (XS) using 'i' as the index. The error occurs while trying to find 'i'. This is because we forgot to pass the block in the call to ada_lookup_encoded_symbol, which this patch fixes. gdb/ChangeLog: * ada-exp.y (write_object_renaming): When subscripting an array using a symbol as the index, pass the block in call to ada_lookup_encoded_symbol when looking that symbol up. gdb/testsuite/ChangeLog: * gdb.ada/rename_subscript_param: New testcase. Tested on x86_64-linux. Note: This requires the following GCC patch: | 2017-04-25 Pierre-Marie de Rodat <derodat@adacore.com> | | * exp_dbug.adb: In Debug_Renaming_Declaration, | when dealing with indexed component, accept to produce a renaming | symbol when the index is an IN parameter or when it is a name | defined in an outer scope.
2018-01-05 10:29:54 +01:00
ada_lookup_encoded_symbol (index_name, orig_left_context,
VAR_DOMAIN, &index_sym_info);
Replace the block_found global with explicit data-flow As Pedro suggested on gdb-patches@ (see https://sourceware.org/ml/gdb-patches/2015-05/msg00714.html), this change makes symbol lookup functions return a structure that includes both the symbol found and the block in which it was found. This makes it possible to get rid of the block_found global variable and thus makes block hunting explicit. gdb/ * ada-exp.y (write_object_renaming): Replace struct ada_symbol_info with struct block_symbol. Update field references accordingly. (block_lookup, select_possible_type_sym): Likewise. (find_primitive_type): Likewise. Also update call to ada_lookup_symbol to extract the symbol itself. (write_var_or_type, write_name_assoc): Likewise. * ada-lang.h (struct ada_symbol_info): Remove. (ada_lookup_symbol_list): Replace struct ada_symbol_info with struct block_symbol. (ada_lookup_encoded_symbol, user_select_syms): Likewise. (ada_lookup_symbol): Return struct block_symbol instead of a mere symbol. * ada-lang.c (defns_collected): Replace struct ada_symbol_info with struct block_symbol. (resolve_subexp, ada_resolve_function, sort_choices, user_select_syms, is_nonfunction, add_defn_to_vec, num_defns_collected, defns_collected, symbols_are_identical_enums, remove_extra_symbols, remove_irrelevant_renamings, add_lookup_symbol_list_worker, ada_lookup_symbol_list, ada_iterate_over_symbols, ada_lookup_encoded_symbol, get_var_value): Likewise. (ada_lookup_symbol): Return a block_symbol instead of a mere symbol. Replace struct ada_symbol_info with struct block_symbol. (ada_lookup_symbol_nonlocal): Likewise. (standard_lookup): Make block passing explicit through lookup_symbol_in_language. * ada-tasks.c (get_tcb_types_info): Update the calls to lookup_symbol_in_language to extract the mere symbol out of the returned value. (ada_tasks_inferior_data_sniffer): Likewise. * ax-gdb.c (gen_static_field): Likewise for the call to lookup_symbol. (gen_maybe_namespace_elt): Deal with struct symbol_in_block from lookup functions. (gen_expr): Likewise. * c-exp.y: Likewise. Remove uses of block_found. (lex_one_token, classify_inner_name, c_print_token): Likewise. (classify_name): Likewise. Rename the "sym" local variable to "bsym". * c-valprint.c (print_unpacked_pointer): Likewise. * compile/compile-c-symbols.c (convert_symbol_sym): Promote the "sym" parameter from struct symbol * to struct block_symbol. Use it to remove uses of block_found. Deal with struct symbol_in_block from lookup functions. (gcc_convert_symbol): Likewise. Update the call to convert_symbol_sym. * compile/compile-object-load.c (compile_object_load): Deal with struct symbol_in_block from lookup functions. * cp-namespace.c (cp_lookup_nested_symbol_1, cp_lookup_nested_symbol, cp_lookup_bare_symbol, cp_search_static_and_baseclasses, cp_lookup_symbol_in_namespace, cp_lookup_symbol_via_imports, cp_lookup_symbol_imports_or_template, cp_lookup_symbol_via_all_imports, cp_lookup_symbol_namespace, lookup_namespace_scope, cp_lookup_nonlocal, find_symbol_in_baseclass): Return struct symbol_in_block instead of mere symbols and deal with struct symbol_in_block from lookup functions. * cp-support.c (inspect_type, replace_typedefs, cp_lookup_rtti_type): Deal with struct symbol_in_block from lookup functions. * cp-support.h (cp_lookup_symbol_nonlocal, cp_lookup_symbol_from_namespace, cp_lookup_symbol_imports_or_template, cp_lookup_nested_symbol): Return struct symbol_in_block instead of mere symbols. * d-exp.y (d_type_from_name, d_module_from_name, push_variable, push_module_name): Deal with struct symbol_in_block from lookup functions. Remove uses of block_found. * eval.c (evaluate_subexp_standard): Update call to cp_lookup_symbol_namespace. * f-exp.y: Deal with struct symbol_in_block from lookup functions. Remove uses of block_found. (yylex): Likewise. * gdbtypes.c (lookup_typename, lookup_struct, lookup_union, lookup_enum, lookup_template_type, check_typedef): Deal with struct symbol_in_block from lookup functions. * guile/scm-frame.c (gdbscm_frame_read_var): Likewise. * guile/scm-symbol.c (gdbscm_lookup_symbol): Likewise. (gdbscm_lookup_global_symbol): Likewise. * gnu-v3-abi.c (gnuv3_get_typeid_type): Likewise. * go-exp.y: Likewise. Remove uses of block_found. (package_name_p, classify_packaged_name, classify_name): Likewise. * infrun.c (insert_exception_resume_breakpoint): Likewise. * jv-exp.y (push_variable): Likewise. * jv-lang.c (java_lookup_class, get_java_object_type): Likewise. * language.c (language_bool_type): Likewise. * language.h (struct language_defn): Update la_lookup_symbol_nonlocal to return a struct symbol_in_block rather than a mere symbol. * linespec.c (find_label_symbols): Deal with struct symbol_in_block from lookup functions. * m2-exp.y: Likewise. Remove uses of block_found. (yylex): Likewise. * mi/mi-cmd-stack.c (list_args_or_locals): Likewise. * objc-lang.c (lookup_struct_typedef, find_imps): Likewise. * p-exp.y: Likewise. Remove uses of block_found. (yylex): Likewise. * p-valprint.c (pascal_val_print): Likewise. * parse.c (write_dollar_variable): Likewise. Remove uses of block_found. * parser-defs.h (struct symtoken): Turn the SYM field into a struct symbol_in_block. * printcmd.c (address_info): Deal with struct symbol_in_block from lookup functions. * python/py-frame.c (frapy_read_var): Likewise. * python/py-symbol.c (gdbpy_lookup_symbol, gdbpy_lookup_global_symbol): Likewise. * skip.c (skip_function_command): Likewise. * solib-darwin.c (darwin_lookup_lib_symbol): Return a struct symbol_in_block instead of a mere symbol. * solib-spu.c (spu_lookup_lib_symbol): Likewise. * solib-svr4.c (elf_lookup_lib_symbol): Likewise. * solib.c (solib_global_lookup): Likewise. * solist.h (solib_global_lookup): Likewise. (struct target_so_ops): Update lookup_lib_global_symbol to return a struct symbol_in_block rather than a mere symbol. * source.c (select_source_symtab): Deal with struct symbol_in_block from lookup functions. * stack.c (print_frame_args, iterate_over_block_arg_vars): Likewise. * symfile.c (set_initial_language): Likewise. * symtab.c (SYMBOL_LOOKUP_FAILED): Turn into a struct symbol_in_block. (SYMBOL_LOOKUP_FAILED_P): New predicate as a macro. (struct symbol_cache_slot): Turn the FOUND field into a struct symbol_in_block. (block_found): Remove. (eq_symbol_entry): Update to deal with struct symbol_in_block in cache slots. (symbol_cache_lookup): Return a struct symbol_in_block rather than a mere symbol. (symbol_cache_mark_found): Add a BLOCK parameter to fill appropriately the cache slots. Update callers. (symbol_cache_dump): Update cache slots handling to the type change. (lookup_symbol_in_language, lookup_symbol, lookup_language_this, lookup_symbol_aux, lookup_local_symbol, lookup_symbol_in_objfile, lookup_global_symbol_from_objfile, lookup_symbol_in_objfile_symtabs, lookup_symbol_in_objfile_from_linkage_name, lookup_symbol_via_quick_fns, basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block, lookup_static_symbol, lookup_global_symbol): Return a struct symbol_in_block rather than a mere symbol. Deal with struct symbol_in_block from other lookup functions. Remove uses of block_found. (lookup_symbol_in_block): Remove uses of block_found. (struct global_sym_lookup_data): Turn the RESULT field into a struct symbol_in_block. (lookup_symbol_global_iterator_cb): Update references to the RESULT field. (search_symbols): Deal with struct symbol_in_block from lookup functions. * symtab.h (struct symbol_in_block): New structure. (block_found): Remove. (lookup_symbol_in_language, lookup_symbol, basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block, looku_static_symbol, lookup_global_symbol, lookup_symbol_in_block, lookup_language_this, lookup_global_symbol_from_objfile): Return a struct symbol_in_block rather than just a mere symbol. Update comments to remove mentions of block_found. * valops.c (find_function_in_inferior, value_struct_elt_for_reference, value_maybe_namespace_elt, value_of_this): Deal with struct symbol_in_block from lookup functions. * value.c (value_static_field, value_fn_field): Likewise.
2015-07-21 17:02:15 +02:00
if (index_sym_info.symbol == NULL)
error (_("Could not find %s"), index_name);
Replace the block_found global with explicit data-flow As Pedro suggested on gdb-patches@ (see https://sourceware.org/ml/gdb-patches/2015-05/msg00714.html), this change makes symbol lookup functions return a structure that includes both the symbol found and the block in which it was found. This makes it possible to get rid of the block_found global variable and thus makes block hunting explicit. gdb/ * ada-exp.y (write_object_renaming): Replace struct ada_symbol_info with struct block_symbol. Update field references accordingly. (block_lookup, select_possible_type_sym): Likewise. (find_primitive_type): Likewise. Also update call to ada_lookup_symbol to extract the symbol itself. (write_var_or_type, write_name_assoc): Likewise. * ada-lang.h (struct ada_symbol_info): Remove. (ada_lookup_symbol_list): Replace struct ada_symbol_info with struct block_symbol. (ada_lookup_encoded_symbol, user_select_syms): Likewise. (ada_lookup_symbol): Return struct block_symbol instead of a mere symbol. * ada-lang.c (defns_collected): Replace struct ada_symbol_info with struct block_symbol. (resolve_subexp, ada_resolve_function, sort_choices, user_select_syms, is_nonfunction, add_defn_to_vec, num_defns_collected, defns_collected, symbols_are_identical_enums, remove_extra_symbols, remove_irrelevant_renamings, add_lookup_symbol_list_worker, ada_lookup_symbol_list, ada_iterate_over_symbols, ada_lookup_encoded_symbol, get_var_value): Likewise. (ada_lookup_symbol): Return a block_symbol instead of a mere symbol. Replace struct ada_symbol_info with struct block_symbol. (ada_lookup_symbol_nonlocal): Likewise. (standard_lookup): Make block passing explicit through lookup_symbol_in_language. * ada-tasks.c (get_tcb_types_info): Update the calls to lookup_symbol_in_language to extract the mere symbol out of the returned value. (ada_tasks_inferior_data_sniffer): Likewise. * ax-gdb.c (gen_static_field): Likewise for the call to lookup_symbol. (gen_maybe_namespace_elt): Deal with struct symbol_in_block from lookup functions. (gen_expr): Likewise. * c-exp.y: Likewise. Remove uses of block_found. (lex_one_token, classify_inner_name, c_print_token): Likewise. (classify_name): Likewise. Rename the "sym" local variable to "bsym". * c-valprint.c (print_unpacked_pointer): Likewise. * compile/compile-c-symbols.c (convert_symbol_sym): Promote the "sym" parameter from struct symbol * to struct block_symbol. Use it to remove uses of block_found. Deal with struct symbol_in_block from lookup functions. (gcc_convert_symbol): Likewise. Update the call to convert_symbol_sym. * compile/compile-object-load.c (compile_object_load): Deal with struct symbol_in_block from lookup functions. * cp-namespace.c (cp_lookup_nested_symbol_1, cp_lookup_nested_symbol, cp_lookup_bare_symbol, cp_search_static_and_baseclasses, cp_lookup_symbol_in_namespace, cp_lookup_symbol_via_imports, cp_lookup_symbol_imports_or_template, cp_lookup_symbol_via_all_imports, cp_lookup_symbol_namespace, lookup_namespace_scope, cp_lookup_nonlocal, find_symbol_in_baseclass): Return struct symbol_in_block instead of mere symbols and deal with struct symbol_in_block from lookup functions. * cp-support.c (inspect_type, replace_typedefs, cp_lookup_rtti_type): Deal with struct symbol_in_block from lookup functions. * cp-support.h (cp_lookup_symbol_nonlocal, cp_lookup_symbol_from_namespace, cp_lookup_symbol_imports_or_template, cp_lookup_nested_symbol): Return struct symbol_in_block instead of mere symbols. * d-exp.y (d_type_from_name, d_module_from_name, push_variable, push_module_name): Deal with struct symbol_in_block from lookup functions. Remove uses of block_found. * eval.c (evaluate_subexp_standard): Update call to cp_lookup_symbol_namespace. * f-exp.y: Deal with struct symbol_in_block from lookup functions. Remove uses of block_found. (yylex): Likewise. * gdbtypes.c (lookup_typename, lookup_struct, lookup_union, lookup_enum, lookup_template_type, check_typedef): Deal with struct symbol_in_block from lookup functions. * guile/scm-frame.c (gdbscm_frame_read_var): Likewise. * guile/scm-symbol.c (gdbscm_lookup_symbol): Likewise. (gdbscm_lookup_global_symbol): Likewise. * gnu-v3-abi.c (gnuv3_get_typeid_type): Likewise. * go-exp.y: Likewise. Remove uses of block_found. (package_name_p, classify_packaged_name, classify_name): Likewise. * infrun.c (insert_exception_resume_breakpoint): Likewise. * jv-exp.y (push_variable): Likewise. * jv-lang.c (java_lookup_class, get_java_object_type): Likewise. * language.c (language_bool_type): Likewise. * language.h (struct language_defn): Update la_lookup_symbol_nonlocal to return a struct symbol_in_block rather than a mere symbol. * linespec.c (find_label_symbols): Deal with struct symbol_in_block from lookup functions. * m2-exp.y: Likewise. Remove uses of block_found. (yylex): Likewise. * mi/mi-cmd-stack.c (list_args_or_locals): Likewise. * objc-lang.c (lookup_struct_typedef, find_imps): Likewise. * p-exp.y: Likewise. Remove uses of block_found. (yylex): Likewise. * p-valprint.c (pascal_val_print): Likewise. * parse.c (write_dollar_variable): Likewise. Remove uses of block_found. * parser-defs.h (struct symtoken): Turn the SYM field into a struct symbol_in_block. * printcmd.c (address_info): Deal with struct symbol_in_block from lookup functions. * python/py-frame.c (frapy_read_var): Likewise. * python/py-symbol.c (gdbpy_lookup_symbol, gdbpy_lookup_global_symbol): Likewise. * skip.c (skip_function_command): Likewise. * solib-darwin.c (darwin_lookup_lib_symbol): Return a struct symbol_in_block instead of a mere symbol. * solib-spu.c (spu_lookup_lib_symbol): Likewise. * solib-svr4.c (elf_lookup_lib_symbol): Likewise. * solib.c (solib_global_lookup): Likewise. * solist.h (solib_global_lookup): Likewise. (struct target_so_ops): Update lookup_lib_global_symbol to return a struct symbol_in_block rather than a mere symbol. * source.c (select_source_symtab): Deal with struct symbol_in_block from lookup functions. * stack.c (print_frame_args, iterate_over_block_arg_vars): Likewise. * symfile.c (set_initial_language): Likewise. * symtab.c (SYMBOL_LOOKUP_FAILED): Turn into a struct symbol_in_block. (SYMBOL_LOOKUP_FAILED_P): New predicate as a macro. (struct symbol_cache_slot): Turn the FOUND field into a struct symbol_in_block. (block_found): Remove. (eq_symbol_entry): Update to deal with struct symbol_in_block in cache slots. (symbol_cache_lookup): Return a struct symbol_in_block rather than a mere symbol. (symbol_cache_mark_found): Add a BLOCK parameter to fill appropriately the cache slots. Update callers. (symbol_cache_dump): Update cache slots handling to the type change. (lookup_symbol_in_language, lookup_symbol, lookup_language_this, lookup_symbol_aux, lookup_local_symbol, lookup_symbol_in_objfile, lookup_global_symbol_from_objfile, lookup_symbol_in_objfile_symtabs, lookup_symbol_in_objfile_from_linkage_name, lookup_symbol_via_quick_fns, basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block, lookup_static_symbol, lookup_global_symbol): Return a struct symbol_in_block rather than a mere symbol. Deal with struct symbol_in_block from other lookup functions. Remove uses of block_found. (lookup_symbol_in_block): Remove uses of block_found. (struct global_sym_lookup_data): Turn the RESULT field into a struct symbol_in_block. (lookup_symbol_global_iterator_cb): Update references to the RESULT field. (search_symbols): Deal with struct symbol_in_block from lookup functions. * symtab.h (struct symbol_in_block): New structure. (block_found): Remove. (lookup_symbol_in_language, lookup_symbol, basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block, looku_static_symbol, lookup_global_symbol, lookup_symbol_in_block, lookup_language_this, lookup_global_symbol_from_objfile): Return a struct symbol_in_block rather than just a mere symbol. Update comments to remove mentions of block_found. * valops.c (find_function_in_inferior, value_struct_elt_for_reference, value_maybe_namespace_elt, value_of_this): Deal with struct symbol_in_block from lookup functions. * value.c (value_static_field, value_fn_field): Likewise.
2015-07-21 17:02:15 +02:00
else if (SYMBOL_CLASS (index_sym_info.symbol) == LOC_TYPEDEF)
* ada-lang.h (ada_renaming_category): New enumerated type. (ada_lookup_encoded_symbol): Declare. (ada_parse_renaming): Declare. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete declarations. * ada-lang.c (ada_parse_renaming): New function to concentrate extraction of information from renaming symbols. (parse_old_style_renaming): New function to concentrate extraction of old-style (purely type-based) renaming information. (renaming_is_visible): Rename to... (old_renaming_is_invisible): Rename and change sense of renaming_is_visible. (remove_out_of_scope_renamings): Rename to... (remove_irrelevant_renamings): Renames remove_out_of_scope_renamings and augments with additional logic to handle cases where the same object renaming is encoded both as a reference variable and an encoded renaming. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete definitions. (ada_lookup_encoded_symbol): New function factored out of ada_lookup_symbol. (ada_lookup_symbol): Reimplement to call ada_lookup_encoded_symbol. (wild_match): Don't reject perfect match of prefix. (ada_find_renaming_symbol): Factor old-style renaming logic into find_old_style_renaming_symbol. (find_old_style_renaming_symbol): New name for content of old ada_find_renaming_symbol. (ada_prefer_type): Reimplement not to use ada_renaming_type. * ada-exp.y (write_object_renaming): Change interface. Reimplement to use new arguments and ada_parse_renaming. Correct blocks used to find array index. (write_var_or_type): Reimplement to use ada_parse_renaming.
2007-12-21 12:50:11 +01:00
/* Index is an old-style renaming symbol. */
index_sym_info.block = orig_left_context;
local variable watchpoint not deleted after leaving scope When debugging an Ada program, and inserting a watchpoint tracking a local variable, the watchpoint doesn't get automatically deleted upon leaving that variable's scope. This watchpoint then starts creating problems later on, when trying to resume the program's execution from a location outside of the watchpoint's scope: (gdb) c Continuing. Breakpoint 2, foo_p708_025 () at foo_p708_025.adb:7 7 Do_Nothing (Val); (gdb) n No frame is currently executing in block pck.get_val. Command aborted. (gdb) c Continuing. No frame is currently executing in block pck.get_val. Command aborted. The expected output is the following: - The program's execution after the first continue should stop as soon as we reach the end of the watchpoint's scope, and the debugger should be deleting it. - Then we can continue until reaching breakpoint 2 above; - After which we should be able to do next/continue as usual. The reason the watchpoint is not automatically deleted at scope exit is because the watchpoint is not marked as being scope-specific (b->exp_valid_block is equal NULL), and this is because the symbol lookup for our local variable failed to set the innermost_block global variable during the lookup. More precisely, if we look at watch_command_1, we do the following: innermost_block = NULL; [...] exp = parse_exp_1 (&arg, 0, 0, 0); [...] exp_valid_block = innermost_block; Currently, innermost_block stays NULL after the call to parse_exp_1. Digging further, this innermost_block is typically set during symbol lookup when the symbol is considered to have a frame-relative address. For instance, in c-exp.y, we see some code like the following: if (symbol_read_needs_frame (sym.symbol)) { if (innermost_block == 0 || contained_in (sym.block, innermost_block)) innermost_block = sym.block; } We actually have the exact same mechanism in ada-exp.y, except that it vhas accidently been turned off. See write_var_from_sym, where we start with: if (orig_left_context == NULL && symbol_read_needs_frame (sym)) { if (innermost_block == 0 || contained_in (block, innermost_block)) innermost_block = block; } In this case, orig_left_context is a parameter, and looking at the point of call in write_var_or_type, we see: if (nsyms == 1) { write_var_from_sym (par_state, block, syms[0].block, syms[0].symbol); In the call above, the paramater we are interested in is "block", which is a parameter for write_var_or_type as well, except we explicitly override its value at the beginning when found to be NULL: if (block == NULL) block = expression_context_block; So the block we pass to write_var_from_sym is not NULL, and we therefore don't set innermost_block, which leads to the watchpoint no longer being marked as scope-specific. The handling of orig_left_context in write_var_from_sym was there to handle the case where a user writes an expression where the symbol is qualified with a scope (Eg: "function::variable"). But it appears that handling this is specifically here is no longer necessary, so this patch simply removes that parameter and the associated check, and then updates all the points of calls. Interestingly, this also affects GDB/MI, and in particular varobjs, because local variables are now properly reported as having a block, which causes the associated varob to have a "thread-id" field. This patch also adjusts a couple of Ada/gdb-mi tests. gdb/ChangeLog: * ada-exp.y (write_var_from_sym): Remove parameter "orig_left_context". Update all callers. gdb/testsuite/ChangeLog: * gdb.ada/scoped_watch: New testcase. * gdb.ada/watch_arg.exp: Adjust expected behavior to the behavior which is actually correct. * gdb.ada/mi_interface.exp: Add missing thread-id in expected varobj. * gdb.ada/mi_var_array.exp: Add missing thread-id in expected varobj.
2017-03-03 17:31:13 +01:00
write_var_from_sym (par_state, index_sym_info.block,
Replace the block_found global with explicit data-flow As Pedro suggested on gdb-patches@ (see https://sourceware.org/ml/gdb-patches/2015-05/msg00714.html), this change makes symbol lookup functions return a structure that includes both the symbol found and the block in which it was found. This makes it possible to get rid of the block_found global variable and thus makes block hunting explicit. gdb/ * ada-exp.y (write_object_renaming): Replace struct ada_symbol_info with struct block_symbol. Update field references accordingly. (block_lookup, select_possible_type_sym): Likewise. (find_primitive_type): Likewise. Also update call to ada_lookup_symbol to extract the symbol itself. (write_var_or_type, write_name_assoc): Likewise. * ada-lang.h (struct ada_symbol_info): Remove. (ada_lookup_symbol_list): Replace struct ada_symbol_info with struct block_symbol. (ada_lookup_encoded_symbol, user_select_syms): Likewise. (ada_lookup_symbol): Return struct block_symbol instead of a mere symbol. * ada-lang.c (defns_collected): Replace struct ada_symbol_info with struct block_symbol. (resolve_subexp, ada_resolve_function, sort_choices, user_select_syms, is_nonfunction, add_defn_to_vec, num_defns_collected, defns_collected, symbols_are_identical_enums, remove_extra_symbols, remove_irrelevant_renamings, add_lookup_symbol_list_worker, ada_lookup_symbol_list, ada_iterate_over_symbols, ada_lookup_encoded_symbol, get_var_value): Likewise. (ada_lookup_symbol): Return a block_symbol instead of a mere symbol. Replace struct ada_symbol_info with struct block_symbol. (ada_lookup_symbol_nonlocal): Likewise. (standard_lookup): Make block passing explicit through lookup_symbol_in_language. * ada-tasks.c (get_tcb_types_info): Update the calls to lookup_symbol_in_language to extract the mere symbol out of the returned value. (ada_tasks_inferior_data_sniffer): Likewise. * ax-gdb.c (gen_static_field): Likewise for the call to lookup_symbol. (gen_maybe_namespace_elt): Deal with struct symbol_in_block from lookup functions. (gen_expr): Likewise. * c-exp.y: Likewise. Remove uses of block_found. (lex_one_token, classify_inner_name, c_print_token): Likewise. (classify_name): Likewise. Rename the "sym" local variable to "bsym". * c-valprint.c (print_unpacked_pointer): Likewise. * compile/compile-c-symbols.c (convert_symbol_sym): Promote the "sym" parameter from struct symbol * to struct block_symbol. Use it to remove uses of block_found. Deal with struct symbol_in_block from lookup functions. (gcc_convert_symbol): Likewise. Update the call to convert_symbol_sym. * compile/compile-object-load.c (compile_object_load): Deal with struct symbol_in_block from lookup functions. * cp-namespace.c (cp_lookup_nested_symbol_1, cp_lookup_nested_symbol, cp_lookup_bare_symbol, cp_search_static_and_baseclasses, cp_lookup_symbol_in_namespace, cp_lookup_symbol_via_imports, cp_lookup_symbol_imports_or_template, cp_lookup_symbol_via_all_imports, cp_lookup_symbol_namespace, lookup_namespace_scope, cp_lookup_nonlocal, find_symbol_in_baseclass): Return struct symbol_in_block instead of mere symbols and deal with struct symbol_in_block from lookup functions. * cp-support.c (inspect_type, replace_typedefs, cp_lookup_rtti_type): Deal with struct symbol_in_block from lookup functions. * cp-support.h (cp_lookup_symbol_nonlocal, cp_lookup_symbol_from_namespace, cp_lookup_symbol_imports_or_template, cp_lookup_nested_symbol): Return struct symbol_in_block instead of mere symbols. * d-exp.y (d_type_from_name, d_module_from_name, push_variable, push_module_name): Deal with struct symbol_in_block from lookup functions. Remove uses of block_found. * eval.c (evaluate_subexp_standard): Update call to cp_lookup_symbol_namespace. * f-exp.y: Deal with struct symbol_in_block from lookup functions. Remove uses of block_found. (yylex): Likewise. * gdbtypes.c (lookup_typename, lookup_struct, lookup_union, lookup_enum, lookup_template_type, check_typedef): Deal with struct symbol_in_block from lookup functions. * guile/scm-frame.c (gdbscm_frame_read_var): Likewise. * guile/scm-symbol.c (gdbscm_lookup_symbol): Likewise. (gdbscm_lookup_global_symbol): Likewise. * gnu-v3-abi.c (gnuv3_get_typeid_type): Likewise. * go-exp.y: Likewise. Remove uses of block_found. (package_name_p, classify_packaged_name, classify_name): Likewise. * infrun.c (insert_exception_resume_breakpoint): Likewise. * jv-exp.y (push_variable): Likewise. * jv-lang.c (java_lookup_class, get_java_object_type): Likewise. * language.c (language_bool_type): Likewise. * language.h (struct language_defn): Update la_lookup_symbol_nonlocal to return a struct symbol_in_block rather than a mere symbol. * linespec.c (find_label_symbols): Deal with struct symbol_in_block from lookup functions. * m2-exp.y: Likewise. Remove uses of block_found. (yylex): Likewise. * mi/mi-cmd-stack.c (list_args_or_locals): Likewise. * objc-lang.c (lookup_struct_typedef, find_imps): Likewise. * p-exp.y: Likewise. Remove uses of block_found. (yylex): Likewise. * p-valprint.c (pascal_val_print): Likewise. * parse.c (write_dollar_variable): Likewise. Remove uses of block_found. * parser-defs.h (struct symtoken): Turn the SYM field into a struct symbol_in_block. * printcmd.c (address_info): Deal with struct symbol_in_block from lookup functions. * python/py-frame.c (frapy_read_var): Likewise. * python/py-symbol.c (gdbpy_lookup_symbol, gdbpy_lookup_global_symbol): Likewise. * skip.c (skip_function_command): Likewise. * solib-darwin.c (darwin_lookup_lib_symbol): Return a struct symbol_in_block instead of a mere symbol. * solib-spu.c (spu_lookup_lib_symbol): Likewise. * solib-svr4.c (elf_lookup_lib_symbol): Likewise. * solib.c (solib_global_lookup): Likewise. * solist.h (solib_global_lookup): Likewise. (struct target_so_ops): Update lookup_lib_global_symbol to return a struct symbol_in_block rather than a mere symbol. * source.c (select_source_symtab): Deal with struct symbol_in_block from lookup functions. * stack.c (print_frame_args, iterate_over_block_arg_vars): Likewise. * symfile.c (set_initial_language): Likewise. * symtab.c (SYMBOL_LOOKUP_FAILED): Turn into a struct symbol_in_block. (SYMBOL_LOOKUP_FAILED_P): New predicate as a macro. (struct symbol_cache_slot): Turn the FOUND field into a struct symbol_in_block. (block_found): Remove. (eq_symbol_entry): Update to deal with struct symbol_in_block in cache slots. (symbol_cache_lookup): Return a struct symbol_in_block rather than a mere symbol. (symbol_cache_mark_found): Add a BLOCK parameter to fill appropriately the cache slots. Update callers. (symbol_cache_dump): Update cache slots handling to the type change. (lookup_symbol_in_language, lookup_symbol, lookup_language_this, lookup_symbol_aux, lookup_local_symbol, lookup_symbol_in_objfile, lookup_global_symbol_from_objfile, lookup_symbol_in_objfile_symtabs, lookup_symbol_in_objfile_from_linkage_name, lookup_symbol_via_quick_fns, basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block, lookup_static_symbol, lookup_global_symbol): Return a struct symbol_in_block rather than a mere symbol. Deal with struct symbol_in_block from other lookup functions. Remove uses of block_found. (lookup_symbol_in_block): Remove uses of block_found. (struct global_sym_lookup_data): Turn the RESULT field into a struct symbol_in_block. (lookup_symbol_global_iterator_cb): Update references to the RESULT field. (search_symbols): Deal with struct symbol_in_block from lookup functions. * symtab.h (struct symbol_in_block): New structure. (block_found): Remove. (lookup_symbol_in_language, lookup_symbol, basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block, looku_static_symbol, lookup_global_symbol, lookup_symbol_in_block, lookup_language_this, lookup_global_symbol_from_objfile): Return a struct symbol_in_block rather than just a mere symbol. Update comments to remove mentions of block_found. * valops.c (find_function_in_inferior, value_struct_elt_for_reference, value_maybe_namespace_elt, value_of_this): Deal with struct symbol_in_block from lookup functions. * value.c (value_static_field, value_fn_field): Likewise.
2015-07-21 17:02:15 +02:00
index_sym_info.symbol);
2002-06-04 17:28:49 +02:00
}
if (slice_state == SIMPLE_INDEX)
{
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_exp_elt_opcode (par_state, OP_FUNCALL);
write_exp_elt_longcst (par_state, (LONGEST) 1);
write_exp_elt_opcode (par_state, OP_FUNCALL);
2002-06-04 17:28:49 +02:00
}
else if (slice_state == LOWER_BOUND)
slice_state = UPPER_BOUND;
else if (slice_state == UPPER_BOUND)
{
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_exp_elt_opcode (par_state, TERNOP_SLICE);
2002-06-04 17:28:49 +02:00
slice_state = SIMPLE_INDEX;
}
break;
case 'R':
{
struct stoken field_name;
const char *end;
char *buf;
* ada-lang.h (ada_renaming_category): New enumerated type. (ada_lookup_encoded_symbol): Declare. (ada_parse_renaming): Declare. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete declarations. * ada-lang.c (ada_parse_renaming): New function to concentrate extraction of information from renaming symbols. (parse_old_style_renaming): New function to concentrate extraction of old-style (purely type-based) renaming information. (renaming_is_visible): Rename to... (old_renaming_is_invisible): Rename and change sense of renaming_is_visible. (remove_out_of_scope_renamings): Rename to... (remove_irrelevant_renamings): Renames remove_out_of_scope_renamings and augments with additional logic to handle cases where the same object renaming is encoded both as a reference variable and an encoded renaming. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete definitions. (ada_lookup_encoded_symbol): New function factored out of ada_lookup_symbol. (ada_lookup_symbol): Reimplement to call ada_lookup_encoded_symbol. (wild_match): Don't reject perfect match of prefix. (ada_find_renaming_symbol): Factor old-style renaming logic into find_old_style_renaming_symbol. (find_old_style_renaming_symbol): New name for content of old ada_find_renaming_symbol. (ada_prefer_type): Reimplement not to use ada_renaming_type. * ada-exp.y (write_object_renaming): Change interface. Reimplement to use new arguments and ada_parse_renaming. Correct blocks used to find array index. (write_var_or_type): Reimplement to use ada_parse_renaming.
2007-12-21 12:50:11 +01:00
renaming_expr += 1;
2002-06-04 17:28:49 +02:00
if (slice_state != SIMPLE_INDEX)
goto BadEncoding;
* ada-lang.h (ada_renaming_category): New enumerated type. (ada_lookup_encoded_symbol): Declare. (ada_parse_renaming): Declare. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete declarations. * ada-lang.c (ada_parse_renaming): New function to concentrate extraction of information from renaming symbols. (parse_old_style_renaming): New function to concentrate extraction of old-style (purely type-based) renaming information. (renaming_is_visible): Rename to... (old_renaming_is_invisible): Rename and change sense of renaming_is_visible. (remove_out_of_scope_renamings): Rename to... (remove_irrelevant_renamings): Renames remove_out_of_scope_renamings and augments with additional logic to handle cases where the same object renaming is encoded both as a reference variable and an encoded renaming. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete definitions. (ada_lookup_encoded_symbol): New function factored out of ada_lookup_symbol. (ada_lookup_symbol): Reimplement to call ada_lookup_encoded_symbol. (wild_match): Don't reject perfect match of prefix. (ada_find_renaming_symbol): Factor old-style renaming logic into find_old_style_renaming_symbol. (find_old_style_renaming_symbol): New name for content of old ada_find_renaming_symbol. (ada_prefer_type): Reimplement not to use ada_renaming_type. * ada-exp.y (write_object_renaming): Change interface. Reimplement to use new arguments and ada_parse_renaming. Correct blocks used to find array index. (write_var_or_type): Reimplement to use ada_parse_renaming.
2007-12-21 12:50:11 +01:00
end = strchr (renaming_expr, 'X');
if (end == NULL)
* ada-lang.h (ada_renaming_category): New enumerated type. (ada_lookup_encoded_symbol): Declare. (ada_parse_renaming): Declare. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete declarations. * ada-lang.c (ada_parse_renaming): New function to concentrate extraction of information from renaming symbols. (parse_old_style_renaming): New function to concentrate extraction of old-style (purely type-based) renaming information. (renaming_is_visible): Rename to... (old_renaming_is_invisible): Rename and change sense of renaming_is_visible. (remove_out_of_scope_renamings): Rename to... (remove_irrelevant_renamings): Renames remove_out_of_scope_renamings and augments with additional logic to handle cases where the same object renaming is encoded both as a reference variable and an encoded renaming. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete definitions. (ada_lookup_encoded_symbol): New function factored out of ada_lookup_symbol. (ada_lookup_symbol): Reimplement to call ada_lookup_encoded_symbol. (wild_match): Don't reject perfect match of prefix. (ada_find_renaming_symbol): Factor old-style renaming logic into find_old_style_renaming_symbol. (find_old_style_renaming_symbol): New name for content of old ada_find_renaming_symbol. (ada_prefer_type): Reimplement not to use ada_renaming_type. * ada-exp.y (write_object_renaming): Change interface. Reimplement to use new arguments and ada_parse_renaming. Correct blocks used to find array index. (write_var_or_type): Reimplement to use ada_parse_renaming.
2007-12-21 12:50:11 +01:00
end = renaming_expr + strlen (renaming_expr);
field_name.length = end - renaming_expr;
Add casts to memory allocation related calls Most allocation functions (if not all) return a void* pointing to the allocated memory. In C++, we need to add an explicit cast when assigning the result to a pointer to another type (which is the case more often than not). The content of this patch is taken from Pedro's branch, from commit "(mostly) auto-generated patch to insert casts needed for C++". I validated that the changes make sense and manually reflowed the code to make it respect the coding style. I also found multiple places where I could use XNEW/XNEWVEC/XRESIZEVEC/etc. Thanks a lot to whoever did that automated script to insert casts, doing it completely by hand would have taken a ridiculous amount of time. Only files built on x86 with --enable-targets=all are modified. This means that all other -nat.c files are untouched and will have to be dealt with later by using appropiate compilers. Or maybe we can try to build them with a regular g++ just to know where to add casts, I don't know. I built-tested this with --enable-targets=all and reg-tested. Here's the changelog entry, which was not too bad to make despite the size, thanks to David Malcom's script. I fixed some bits by hand, but there might be some wrong parts left (hopefully not). gdb/ChangeLog: * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Add cast to allocation result assignment. * ada-exp.y (write_object_renaming): Likewise. (write_ambiguous_var): Likewise. (ada_nget_field_index): Likewise. (write_var_or_type): Likewise. * ada-lang.c (ada_decode_symbol): Likewise. (ada_value_assign): Likewise. (value_pointer): Likewise. (cache_symbol): Likewise. (add_nonlocal_symbols): Likewise. (ada_name_for_lookup): Likewise. (symbol_completion_add): Likewise. (ada_to_fixed_type_1): Likewise. (ada_get_next_arg): Likewise. (defns_collected): Likewise. * ada-lex.l (processId): Likewise. (processString): Likewise. * ada-tasks.c (read_known_tasks_array): Likewise. (read_known_tasks_list): Likewise. * ada-typeprint.c (decoded_type_name): Likewise. * addrmap.c (addrmap_mutable_create_fixed): Likewise. * amd64-tdep.c (amd64_push_arguments): Likewise. (amd64_displaced_step_copy_insn): Likewise. (amd64_classify_insn_at): Likewise. (amd64_relocate_instruction): Likewise. * amd64obsd-tdep.c (amd64obsd_sigtramp_p): Likewise. * arch-utils.c (simple_displaced_step_copy_insn): Likewise. (initialize_current_architecture): Likewise. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * arm-symbian-tdep.c (arm_symbian_osabi_sniffer): Likewise. * arm-tdep.c (arm_exidx_new_objfile): Likewise. (arm_push_dummy_call): Likewise. (extend_buffer_earlier): Likewise. (arm_adjust_breakpoint_address): Likewise. (arm_skip_stub): Likewise. * auto-load.c (filename_is_in_pattern): Likewise. (maybe_add_script_file): Likewise. (maybe_add_script_text): Likewise. (auto_load_objfile_script_1): Likewise. * auxv.c (ld_so_xfer_auxv): Likewise. * ax-general.c (new_agent_expr): Likewise. (grow_expr): Likewise. (ax_reg_mask): Likewise. * bcache.c (bcache_full): Likewise. * breakpoint.c (program_breakpoint_here_p): Likewise. * btrace.c (parse_xml_raw): Likewise. * build-id.c (build_id_to_debug_bfd): Likewise. * buildsym.c (end_symtab_with_blockvector): Likewise. * c-exp.y (string_exp): Likewise. (qualified_name): Likewise. (write_destructor_name): Likewise. (operator_stoken): Likewise. (parse_number): Likewise. (scan_macro_expansion): Likewise. (yylex): Likewise. (c_print_token): Likewise. * c-lang.c (c_get_string): Likewise. (emit_numeric_character): Likewise. * charset.c (wchar_iterate): Likewise. * cli/cli-cmds.c (complete_command): Likewise. (make_command): Likewise. * cli/cli-dump.c (restore_section_callback): Likewise. (restore_binary_file): Likewise. * cli/cli-interp.c (cli_interpreter_exec): Likewise. * cli/cli-script.c (execute_control_command): Likewise. * cli/cli-setshow.c (do_set_command): Likewise. * coff-pe-read.c (add_pe_forwarded_sym): Likewise. (read_pe_exported_syms): Likewise. * coffread.c (coff_read_struct_type): Likewise. (coff_read_enum_type): Likewise. * common/btrace-common.c (btrace_data_append): Likewise. * common/buffer.c (buffer_grow): Likewise. * common/filestuff.c (gdb_fopen_cloexec): Likewise. * common/format.c (parse_format_string): Likewise. * common/gdb_vecs.c (delim_string_to_char_ptr_vec_append): Likewise. * common/xml-utils.c (xml_escape_text): Likewise. * compile/compile-object-load.c (copy_sections): Likewise. (compile_object_load): Likewise. * compile/compile-object-run.c (compile_object_run): Likewise. * completer.c (filename_completer): Likewise. * corefile.c (read_memory_typed_address): Likewise. (write_memory_unsigned_integer): Likewise. (write_memory_signed_integer): Likewise. (complete_set_gnutarget): Likewise. * corelow.c (get_core_register_section): Likewise. * cp-name-parser.y (d_grab): Likewise. (allocate_info): Likewise. (cp_new_demangle_parse_info): Likewise. * cp-namespace.c (cp_scan_for_anonymous_namespaces): Likewise. (cp_lookup_symbol_in_namespace): Likewise. (lookup_namespace_scope): Likewise. (find_symbol_in_baseclass): Likewise. (cp_lookup_nested_symbol): Likewise. (cp_lookup_transparent_type_loop): Likewise. * cp-support.c (copy_string_to_obstack): Likewise. (make_symbol_overload_list): Likewise. (make_symbol_overload_list_namespace): Likewise. (make_symbol_overload_list_adl_namespace): Likewise. (first_component_command): Likewise. * cp-valprint.c (cp_print_value): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * d-exp.y (StringExp): Likewise. * d-namespace.c (d_lookup_symbol_in_module): Likewise. (lookup_module_scope): Likewise. (find_symbol_in_baseclass): Likewise. (d_lookup_nested_symbol): Likewise. * dbxread.c (find_stab_function_addr): Likewise. (read_dbx_symtab): Likewise. (dbx_end_psymtab): Likewise. (cp_set_block_scope): Likewise. * dcache.c (dcache_alloc): Likewise. * demangle.c (_initialize_demangler): Likewise. * dicos-tdep.c (dicos_load_module_p): Likewise. * dictionary.c (dict_create_hashed_expandable): Likewise. (dict_create_linear_expandable): Likewise. (expand_hashtable): Likewise. (add_symbol_linear_expandable): Likewise. * dwarf2-frame.c (add_cie): Likewise. (add_fde): Likewise. (dwarf2_build_frame_info): Likewise. * dwarf2expr.c (dwarf_expr_grow_stack): Likewise. (dwarf_expr_fetch_address): Likewise. (add_piece): Likewise. (execute_stack_op): Likewise. * dwarf2loc.c (chain_candidate): Likewise. (dwarf_entry_parameter_to_value): Likewise. (read_pieced_value): Likewise. (write_pieced_value): Likewise. * dwarf2read.c (dwarf2_read_section): Likewise. (add_type_unit): Likewise. (read_comp_units_from_section): Likewise. (fixup_go_packaging): Likewise. (dwarf2_compute_name): Likewise. (dwarf2_physname): Likewise. (create_dwo_unit_in_dwp_v1): Likewise. (create_dwo_unit_in_dwp_v2): Likewise. (read_func_scope): Likewise. (read_call_site_scope): Likewise. (dwarf2_attach_fields_to_type): Likewise. (process_structure_scope): Likewise. (mark_common_block_symbol_computed): Likewise. (read_common_block): Likewise. (abbrev_table_read_table): Likewise. (guess_partial_die_structure_name): Likewise. (fixup_partial_die): Likewise. (add_file_name): Likewise. (dwarf2_const_value_data): Likewise. (dwarf2_const_value_attr): Likewise. (build_error_marker_type): Likewise. (guess_full_die_structure_name): Likewise. (anonymous_struct_prefix): Likewise. (typename_concat): Likewise. (dwarf2_canonicalize_name): Likewise. (dwarf2_name): Likewise. (write_constant_as_bytes): Likewise. (dwarf2_fetch_constant_bytes): Likewise. (copy_string): Likewise. (parse_macro_definition): Likewise. * elfread.c (elf_symfile_segments): Likewise. (elf_rel_plt_read): Likewise. (elf_gnu_ifunc_resolve_by_cache): Likewise. (elf_gnu_ifunc_resolve_by_got): Likewise. (elf_read_minimal_symbols): Likewise. (elf_gnu_ifunc_record_cache): Likewise. * event-top.c (top_level_prompt): Likewise. (command_line_handler): Likewise. * exec.c (resize_section_table): Likewise. * expprint.c (print_subexp_standard): Likewise. * fbsd-tdep.c (fbsd_collect_regset_section_cb): Likewise. * findcmd.c (parse_find_args): Likewise. * findvar.c (address_from_register): Likewise. * frame.c (get_prev_frame_always): Likewise. * gdb_bfd.c (gdb_bfd_ref): Likewise. (get_section_descriptor): Likewise. * gdb_obstack.c (obconcat): Likewise. (obstack_strdup): Likewise. * gdbtypes.c (lookup_function_type_with_arguments): Likewise. (create_set_type): Likewise. (lookup_unsigned_typename): Likewise. (lookup_signed_typename): Likewise. (resolve_dynamic_union): Likewise. (resolve_dynamic_struct): Likewise. (add_dyn_prop): Likewise. (copy_dynamic_prop_list): Likewise. (arch_flags_type): Likewise. (append_composite_type_field_raw): Likewise. * gdbtypes.h (INIT_FUNC_SPECIFIC): Likewise. * gnu-v3-abi.c (gnuv3_rtti_type): Likewise. * go-exp.y (string_exp): Likewise. * go-lang.c (go_demangle): Likewise. * guile/guile.c (compute_scheme_string): Likewise. * guile/scm-cmd.c (gdbscm_parse_command_name): Likewise. (gdbscm_canonicalize_command_name): Likewise. * guile/scm-ports.c (ioscm_init_stdio_buffers): Likewise. (ioscm_init_memory_port): Likewise. (ioscm_reinit_memory_port): Likewise. * guile/scm-utils.c (gdbscm_gc_xstrdup): Likewise. (gdbscm_gc_dup_argv): Likewise. * h8300-tdep.c (h8300_push_dummy_call): Likewise. * hppa-tdep.c (internalize_unwinds): Likewise. (read_unwind_info): Likewise. * i386-cygwin-tdep.c (core_process_module_section): Likewise. (windows_core_xfer_shared_libraries): Likewise. * i386-tdep.c (i386_displaced_step_copy_insn): Likewise. (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * i386obsd-tdep.c (i386obsd_sigtramp_p): Likewise. * inf-child.c (inf_child_fileio_readlink): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. (inf_ptrace_store_register): Likewise. * infrun.c (follow_exec): Likewise. (displaced_step_prepare_throw): Likewise. (save_stop_context): Likewise. (save_infcall_suspend_state): Likewise. * jit.c (jit_read_descriptor): Likewise. (jit_read_code_entry): Likewise. (jit_symtab_line_mapping_add_impl): Likewise. (finalize_symtab): Likewise. (jit_unwind_reg_get_impl): Likewise. * jv-exp.y (QualifiedName): Likewise. * jv-lang.c (get_java_utf8_name): Likewise. (type_from_class): Likewise. (java_demangle_type_signature): Likewise. (java_class_name_from_physname): Likewise. * jv-typeprint.c (java_type_print_base): Likewise. * jv-valprint.c (java_value_print): Likewise. * language.c (add_language): Likewise. * linespec.c (add_sal_to_sals_basic): Likewise. (add_sal_to_sals): Likewise. (decode_objc): Likewise. (find_linespec_symbols): Likewise. * linux-fork.c (fork_save_infrun_state): Likewise. * linux-nat.c (linux_nat_detach): Likewise. (linux_nat_fileio_readlink): Likewise. * linux-record.c (record_linux_sockaddr): Likewise. (record_linux_msghdr): Likewise. (Do): Likewise. * linux-tdep.c (linux_core_info_proc_mappings): Likewise. (linux_collect_regset_section_cb): Likewise. (linux_get_siginfo_data): Likewise. * linux-thread-db.c (try_thread_db_load_from_pdir_1): Likewise. (try_thread_db_load_from_dir): Likewise. (thread_db_load_search): Likewise. (info_auto_load_libthread_db): Likewise. * m32c-tdep.c (m32c_m16c_address_to_pointer): Likewise. (m32c_m16c_pointer_to_address): Likewise. * m68hc11-tdep.c (m68hc11_pseudo_register_write): Likewise. * m68k-tdep.c (m68k_get_longjmp_target): Likewise. * machoread.c (macho_check_dsym): Likewise. * macroexp.c (resize_buffer): Likewise. (gather_arguments): Likewise. (maybe_expand): Likewise. * macrotab.c (new_macro_key): Likewise. (new_source_file): Likewise. (new_macro_definition): Likewise. * mdebugread.c (parse_symbol): Likewise. (parse_type): Likewise. (parse_partial_symbols): Likewise. (psymtab_to_symtab_1): Likewise. * mem-break.c (default_memory_insert_breakpoint): Likewise. * mi/mi-cmd-break.c (mi_argv_to_format): Likewise. * mi/mi-main.c (mi_cmd_data_read_memory): Likewise. (mi_cmd_data_read_memory_bytes): Likewise. (mi_cmd_data_write_memory_bytes): Likewise. (mi_cmd_trace_frame_collected): Likewise. * mi/mi-parse.c (mi_parse_argv): Likewise. (mi_parse): Likewise. * minidebug.c (lzma_open): Likewise. (lzma_pread): Likewise. * mips-tdep.c (mips_read_fp_register_single): Likewise. (mips_print_fp_register): Likewise. * mipsnbsd-tdep.c (mipsnbsd_get_longjmp_target): Likewise. * mipsread.c (read_alphacoff_dynamic_symtab): Likewise. * mt-tdep.c (mt_register_name): Likewise. (mt_registers_info): Likewise. (mt_push_dummy_call): Likewise. * namespace.c (add_using_directive): Likewise. * nat/linux-btrace.c (perf_event_read): Likewise. (linux_enable_bts): Likewise. * nat/linux-osdata.c (linux_common_core_of_thread): Likewise. * nat/linux-ptrace.c (linux_ptrace_test_ret_to_nx): Likewise. * nto-tdep.c (nto_find_and_open_solib): Likewise. (nto_parse_redirection): Likewise. * objc-lang.c (objc_demangle): Likewise. (find_methods): Likewise. * objfiles.c (get_objfile_bfd_data): Likewise. (set_objfile_main_name): Likewise. (allocate_objfile): Likewise. (objfile_relocate): Likewise. (update_section_map): Likewise. * osabi.c (generic_elf_osabi_sniff_abi_tag_sections): Likewise. * p-exp.y (exp): Likewise. (yylex): Likewise. * p-valprint.c (pascal_object_print_value): Likewise. * parse.c (initialize_expout): Likewise. (mark_completion_tag): Likewise. (copy_name): Likewise. (parse_float): Likewise. (type_stack_reserve): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. (ppu2spu_prev_register): Likewise. * ppc-ravenscar-thread.c (supply_register_at_address): Likewise. * printcmd.c (printf_wide_c_string): Likewise. (printf_pointer): Likewise. * probe.c (parse_probes): Likewise. * python/py-cmd.c (gdbpy_parse_command_name): Likewise. (cmdpy_init): Likewise. * python/py-gdb-readline.c (gdbpy_readline_wrapper): Likewise. * python/py-symtab.c (set_sal): Likewise. * python/py-unwind.c (pyuw_sniffer): Likewise. * python/python.c (python_interactive_command): Likewise. (compute_python_string): Likewise. * ravenscar-thread.c (get_running_thread_id): Likewise. * record-full.c (record_full_exec_insn): Likewise. (record_full_core_open_1): Likewise. * regcache.c (regcache_raw_read_signed): Likewise. (regcache_raw_read_unsigned): Likewise. (regcache_cooked_read_signed): Likewise. (regcache_cooked_read_unsigned): Likewise. * remote-fileio.c (remote_fileio_func_open): Likewise. (remote_fileio_func_rename): Likewise. (remote_fileio_func_unlink): Likewise. (remote_fileio_func_stat): Likewise. (remote_fileio_func_system): Likewise. * remote-mips.c (mips_xfer_memory): Likewise. (mips_load_srec): Likewise. (pmon_end_download): Likewise. * remote.c (new_remote_state): Likewise. (map_regcache_remote_table): Likewise. (remote_register_number_and_offset): Likewise. (init_remote_state): Likewise. (get_memory_packet_size): Likewise. (remote_pass_signals): Likewise. (remote_program_signals): Likewise. (remote_start_remote): Likewise. (remote_check_symbols): Likewise. (remote_query_supported): Likewise. (extended_remote_attach): Likewise. (process_g_packet): Likewise. (store_registers_using_G): Likewise. (putpkt_binary): Likewise. (read_frame): Likewise. (compare_sections_command): Likewise. (remote_hostio_pread): Likewise. (remote_hostio_readlink): Likewise. (remote_file_put): Likewise. (remote_file_get): Likewise. (remote_pid_to_exec_file): Likewise. (_initialize_remote): Likewise. * rs6000-aix-tdep.c (rs6000_aix_ld_info_to_xml): Likewise. (rs6000_aix_core_xfer_shared_libraries_aix): Likewise. * rs6000-tdep.c (ppc_displaced_step_copy_insn): Likewise. (bfd_uses_spe_extensions): Likewise. * s390-linux-tdep.c (s390_displaced_step_copy_insn): Likewise. * score-tdep.c (score7_malloc_and_get_memblock): Likewise. * solib-dsbt.c (decode_loadmap): Likewise. (fetch_loadmap): Likewise. (scan_dyntag): Likewise. (enable_break): Likewise. (dsbt_relocate_main_executable): Likewise. * solib-frv.c (fetch_loadmap): Likewise. (enable_break2): Likewise. (frv_relocate_main_executable): Likewise. * solib-spu.c (spu_relocate_main_executable): Likewise. (spu_bfd_open): Likewise. * solib-svr4.c (lm_info_read): Likewise. (read_program_header): Likewise. (find_program_interpreter): Likewise. (scan_dyntag): Likewise. (elf_locate_base): Likewise. (open_symbol_file_object): Likewise. (read_program_headers_from_bfd): Likewise. (svr4_relocate_main_executable): Likewise. * solib-target.c (solib_target_relocate_section_addresses): Likewise. * solib.c (solib_find_1): Likewise. (exec_file_find): Likewise. (solib_find): Likewise. * source.c (openp): Likewise. (print_source_lines_base): Likewise. (forward_search_command): Likewise. * sparc-ravenscar-thread.c (supply_register_at_address): Likewise. * spu-tdep.c (spu2ppu_prev_register): Likewise. (spu_get_overlay_table): Likewise. * stabsread.c (patch_block_stabs): Likewise. (define_symbol): Likewise. (again:): Likewise. (read_member_functions): Likewise. (read_one_struct_field): Likewise. (read_enum_type): Likewise. (common_block_start): Likewise. * stack.c (read_frame_arg): Likewise. (backtrace_command): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. * symfile.c (syms_from_objfile_1): Likewise. (find_separate_debug_file): Likewise. (load_command): Likewise. (load_progress): Likewise. (load_section_callback): Likewise. (reread_symbols): Likewise. (add_filename_language): Likewise. (allocate_compunit_symtab): Likewise. (read_target_long_array): Likewise. (simple_read_overlay_table): Likewise. * symtab.c (symbol_set_names): Likewise. (resize_symbol_cache): Likewise. (rbreak_command): Likewise. (completion_list_add_name): Likewise. (completion_list_objc_symbol): Likewise. (add_filename_to_list): Likewise. * target-descriptions.c (maint_print_c_tdesc_cmd): Likewise. * target-memory.c (target_write_memory_blocks): Likewise. * target.c (target_read_string): Likewise. (read_whatever_is_readable): Likewise. (target_read_alloc_1): Likewise. (simple_search_memory): Likewise. (target_fileio_read_alloc_1): Likewise. * tilegx-tdep.c (tilegx_push_dummy_call): Likewise. * top.c (command_line_input): Likewise. * tracefile-tfile.c (tfile_fetch_registers): Likewise. * tracefile.c (tracefile_fetch_registers): Likewise. * tracepoint.c (add_memrange): Likewise. (init_collection_list): Likewise. (add_aexpr): Likewise. (trace_dump_actions): Likewise. (parse_trace_status): Likewise. (parse_tracepoint_definition): Likewise. (parse_tsv_definition): Likewise. (parse_static_tracepoint_marker_definition): Likewise. * tui/tui-file.c (tui_sfileopen): Likewise. (tui_file_adjust_strbuf): Likewise. * tui/tui-io.c (tui_expand_tabs): Likewise. * tui/tui-source.c (tui_set_source_content): Likewise. * typeprint.c (find_global_typedef): Likewise. * ui-file.c (do_ui_file_xstrdup): Likewise. (ui_file_obsavestring): Likewise. (mem_file_write): Likewise. * utils.c (make_hex_string): Likewise. (get_regcomp_error): Likewise. (puts_filtered_tabular): Likewise. (gdb_realpath_keepfile): Likewise. (ldirname): Likewise. (gdb_bfd_errmsg): Likewise. (substitute_path_component): Likewise. * valops.c (search_struct_method): Likewise. (find_oload_champ_namespace_loop): Likewise. * valprint.c (print_decimal_chars): Likewise. (read_string): Likewise. (generic_emit_char): Likewise. * varobj.c (varobj_delete): Likewise. (varobj_value_get_print_value): Likewise. * vaxobsd-tdep.c (vaxobsd_sigtramp_sniffer): Likewise. * windows-tdep.c (display_one_tib): Likewise. * xcoffread.c (read_xcoff_symtab): Likewise. (process_xcoff_symbol): Likewise. (swap_sym): Likewise. (scan_xcoff_symtab): Likewise. (xcoff_initial_scan): Likewise. * xml-support.c (gdb_xml_end_element): Likewise. (xml_process_xincludes): Likewise. (xml_fetch_content_from_file): Likewise. * xml-syscall.c (xml_list_of_syscalls): Likewise. * xstormy16-tdep.c (xstormy16_push_dummy_call): Likewise. gdb/gdbserver/ChangeLog: * ax.c (gdb_parse_agent_expr): Add cast to allocation result assignment. (gdb_unparse_agent_expr): Likewise. * hostio.c (require_data): Likewise. (handle_pread): Likewise. * linux-low.c (disable_regset): Likewise. (fetch_register): Likewise. (store_register): Likewise. (get_dynamic): Likewise. (linux_qxfer_libraries_svr4): Likewise. * mem-break.c (delete_fast_tracepoint_jump): Likewise. (set_fast_tracepoint_jump): Likewise. (uninsert_fast_tracepoint_jumps_at): Likewise. (reinsert_fast_tracepoint_jumps_at): Likewise. (validate_inserted_breakpoint): Likewise. (clone_agent_expr): Likewise. * regcache.c (init_register_cache): Likewise. * remote-utils.c (putpkt_binary_1): Likewise. (decode_M_packet): Likewise. (decode_X_packet): Likewise. (look_up_one_symbol): Likewise. (relocate_instruction): Likewise. (monitor_output): Likewise. * server.c (handle_search_memory): Likewise. (handle_qxfer_exec_file): Likewise. (handle_qxfer_libraries): Likewise. (handle_qxfer): Likewise. (handle_query): Likewise. (handle_v_cont): Likewise. (handle_v_run): Likewise. (captured_main): Likewise. * target.c (write_inferior_memory): Likewise. * thread-db.c (try_thread_db_load_from_dir): Likewise. * tracepoint.c (init_trace_buffer): Likewise. (add_tracepoint_action): Likewise. (add_traceframe): Likewise. (add_traceframe_block): Likewise. (cmd_qtdpsrc): Likewise. (cmd_qtdv): Likewise. (cmd_qtstatus): Likewise. (response_source): Likewise. (response_tsv): Likewise. (cmd_qtnotes): Likewise. (gdb_collect): Likewise. (initialize_tracepoint): Likewise.
2015-09-25 20:08:06 +02:00
buf = (char *) malloc (end - renaming_expr + 1);
field_name.ptr = buf;
strncpy (buf, renaming_expr, end - renaming_expr);
buf[end - renaming_expr] = '\000';
* ada-lang.h (ada_renaming_category): New enumerated type. (ada_lookup_encoded_symbol): Declare. (ada_parse_renaming): Declare. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete declarations. * ada-lang.c (ada_parse_renaming): New function to concentrate extraction of information from renaming symbols. (parse_old_style_renaming): New function to concentrate extraction of old-style (purely type-based) renaming information. (renaming_is_visible): Rename to... (old_renaming_is_invisible): Rename and change sense of renaming_is_visible. (remove_out_of_scope_renamings): Rename to... (remove_irrelevant_renamings): Renames remove_out_of_scope_renamings and augments with additional logic to handle cases where the same object renaming is encoded both as a reference variable and an encoded renaming. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete definitions. (ada_lookup_encoded_symbol): New function factored out of ada_lookup_symbol. (ada_lookup_symbol): Reimplement to call ada_lookup_encoded_symbol. (wild_match): Don't reject perfect match of prefix. (ada_find_renaming_symbol): Factor old-style renaming logic into find_old_style_renaming_symbol. (find_old_style_renaming_symbol): New name for content of old ada_find_renaming_symbol. (ada_prefer_type): Reimplement not to use ada_renaming_type. * ada-exp.y (write_object_renaming): Change interface. Reimplement to use new arguments and ada_parse_renaming. Correct blocks used to find array index. (write_var_or_type): Reimplement to use ada_parse_renaming.
2007-12-21 12:50:11 +01:00
renaming_expr = end;
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_exp_op_with_string (par_state, STRUCTOP_STRUCT, field_name);
2002-06-04 17:28:49 +02:00
break;
}
2002-06-04 17:28:49 +02:00
default:
goto BadEncoding;
}
}
if (slice_state == SIMPLE_INDEX)
return;
BadEncoding:
* ada-lang.h (ada_renaming_category): New enumerated type. (ada_lookup_encoded_symbol): Declare. (ada_parse_renaming): Declare. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete declarations. * ada-lang.c (ada_parse_renaming): New function to concentrate extraction of information from renaming symbols. (parse_old_style_renaming): New function to concentrate extraction of old-style (purely type-based) renaming information. (renaming_is_visible): Rename to... (old_renaming_is_invisible): Rename and change sense of renaming_is_visible. (remove_out_of_scope_renamings): Rename to... (remove_irrelevant_renamings): Renames remove_out_of_scope_renamings and augments with additional logic to handle cases where the same object renaming is encoded both as a reference variable and an encoded renaming. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete definitions. (ada_lookup_encoded_symbol): New function factored out of ada_lookup_symbol. (ada_lookup_symbol): Reimplement to call ada_lookup_encoded_symbol. (wild_match): Don't reject perfect match of prefix. (ada_find_renaming_symbol): Factor old-style renaming logic into find_old_style_renaming_symbol. (find_old_style_renaming_symbol): New name for content of old ada_find_renaming_symbol. (ada_prefer_type): Reimplement not to use ada_renaming_type. * ada-exp.y (write_object_renaming): Change interface. Reimplement to use new arguments and ada_parse_renaming. Correct blocks used to find array index. (write_var_or_type): Reimplement to use ada_parse_renaming.
2007-12-21 12:50:11 +01:00
error (_("Internal error in encoding of renaming declaration"));
2002-06-04 17:28:49 +02:00
}
constify struct block in some places This makes some spots in gdb, particularly general_symbol_info, use a "const struct block", then fixes the fallout. The justification is that, ordinarily, blocks ought to be readonly. Note though that we can't add "const" in the blockvector due to block relocation. This can be done once blocks are made independent of the program space. 2014-06-18 Tom Tromey <tromey@redhat.com> * varobj.c (varobj_create): Update. * valops.c (value_of_this): Update. * tracepoint.c (add_local_symbols, scope_info): Update. * symtab.h (struct general_symbol_info) <block>: Now const. * symtab.c (skip_prologue_sal) (default_make_symbol_completion_list_break_on) (skip_prologue_using_sal): Update. * stack.h (iterate_over_block_locals) (iterate_over_block_local_vars): Update. * stack.c (print_frame_args): Update. (iterate_over_block_locals, iterate_over_block_local_vars): Make parameter const. (get_selected_block): Make return type const. * python/py-frame.c (frapy_block): Update. * python/py-block.c (gdbpy_block_for_pc): Update. * p-exp.y (%union) <bval>: Now const. * mi/mi-cmd-stack.c (list_args_or_locals): Update. * mdebugread.c (mylookup_symbol, parse_procedure): Update. * m2-exp.y (%union) <bval>: Now const. * linespec.c (get_current_search_block): Make return type const. (create_sals_line_offset, find_label_symbols): Update. * inline-frame.c (inline_frame_sniffer, skip_inline_frames): Update. (block_starting_point_at): Make "block" const. * infrun.c (insert_exception_resume_breakpoint): Make "b" const. (check_exception_resume): Update. * guile/scm-frame.c (gdbscm_frame_block): Update. * guile/scm-block.c (gdbscm_lookup_block): Update. * frame.h (get_frame_block): Update. (get_selected_block): Make return type const. * frame.c (frame_id_inner): Update. * f-valprint.c (info_common_command_for_block) (info_common_command): Update. * dwarf2loc.c (dwarf2_find_location_expression) (dwarf_expr_frame_base, dwarf2_compile_expr_to_ax) (locexpr_describe_location_piece): Update. * c-exp.y (%union) <bval>: Now const. * breakpoint.c (resolve_sal_pc): Update. * blockframe.c (get_frame_block):Make return type const. (get_pc_function_start, get_frame_function, find_pc_sect_function) (block_innermost_frame): Update. * block.h (blockvector_for_pc, blockvector_for_pc_sect) (block_for_pc, block_for_pc_sect): Update. * block.c (blockvector_for_pc_sect, blockvector_for_pc): Make 'pblock' const. (block_for_pc_sect, block_for_pc): Make return type const. * ax-gdb.c (gen_expr): Update. * alpha-mdebug-tdep.c (find_proc_desc): Update. * ada-lang.c (ada_read_renaming_var_value): Make 'block' const. (ada_make_symbol_completion_list, ada_add_exceptions_from_frame) (ada_read_var_value): Update. * ada-exp.y (struct name_info) <block>: Now const. (%union): Likewise. (block_lookup): Constify.
2013-03-12 16:51:37 +01:00
static const struct block*
block_lookup (const struct block *context, const char *raw_name)
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
{
const char *name;
std::vector<struct block_symbol> syms;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
int nsyms;
struct symtab *symtab;
(Ada) GDB crash printing expression with type casting One of our users reported that trying to print the following expression, caused GDB to SEGV: (gdb) print some_package.some_type (val) In this particular instance, the crash occurred inside ada_args_match because it is given a NULL "func", leading to the SEGV because of: struct type *func_type = SYMBOL_TYPE (func); This NULL symbol comes from a list of symbols which was given to ada_resolve_function (parameter called "syms") which then iterates over each of them to discard the ones that don't match the actuals: for (k = 0; k < nsyms; k += 1) { struct type *type = ada_check_typedef (SYMBOL_TYPE (syms[k].symbol)); if (ada_args_match (syms[k].symbol, args, nargs) && (fallback || return_match (type, context_type))) [...] } What's really interesting is that, when entering the block above for the first time, all entries in SYMS have a valid (non-NULL) symbol. However, once we return from the call to ada_check_typedef, the first entry of our SYMS table gets set to all zeros: (gdb) p syms[0] $2 = {symbol = 0x0, block = 0x0} Hence the call to ada_args_match with a NULL symbol, and the ensuing SEGV. To find out why this happen, we need to step back a little and look at how syms was allocated. This list of symbols comes from a symbol lookup, which means ada_lookup_symbol_list_worker. We have our first hint when we look at the function's documentation and see: This vector is transient---good only to the next call of ada_lookup_symbol_list. Implementation-wise, this is done by using a static global obstack, which we just re-initialize each time ada_lookup_symbol_list_worker gets called: obstack_free (&symbol_list_obstack, NULL); obstack_init (&symbol_list_obstack); This property was probably established in order to facilitate the use of the returned vector, since the users of that function would not have to worry about releasing that memory when no longer needed. However, I found during this investigation that it is all to easy to indirectly trigger another symbol lookup while still using the results of a previous lookup. In our particular case, there is the call to ada_check_typedef, which leads to check_typedef. As it happens, my first symbol had a type which was a typedef to a stub type, so check_typedef calls lookup_symbol to find the non-stub version. This in turn eventually leads us back to ada_lookup_symbol_list_worker, where the first thing it does is free the memory area when our list of symbols have been residing and then recreates a new one. in other words, SYMS then becomes a dangling pointer! This patch fixes the issue by having ada_lookup_symbol_list_worker return a copy of the list of symbols, with the responsibility of deallocating that list now transfered to the users of that list. More generally speaking, it is absolutely amazing that we haven't seen consequences of this issue before. This can happen fairly frequently. For instance, I found that ada-exp.y::write_var_or_type calls ada_lookup_symbol_list, and then, while processing that list, calls select_possible_type_sym, which leads to ada_prefer_type, eventually leading to ada_check_typedef again (via eg. ada_is_array_descriptor_type). Even more amazing is the fact that, while I was able to produce multiple scenarios where the corruption occurs, none of them leads to incorrect behavior at the user level. In other words, it requires a very precise set of conditions for the corruption to become user-visible, and despite having a megalarge program where the crash occured, using that as a template for creating a reproducer did not work (pb goes away). This is why this patch does not come with a reproducer. On the other hand, this should not be a problem in terms of testing coverage, as the changes are made in common areas which, at least for the most part, are routinely exercised during testing. gdb/ChangeLog: * ada-lang.c (symbol_list_obstack): Delete. (resolve_subexp): Make sure "candidates" gets xfree'ed. (ada_lookup_symbol_list_worker): Remove the limitation that the result is only good until the next call, now making it the responsibility of the caller to free the result when no longer needed. Adjust the function's intro comment accordingly. (ada_lookup_symbol_list): Adjust the function's intro comment. (ada_iterate_over_symbols): Make sure "results" gets xfree'ed. (ada_lookup_encoded_symbol, get_var_value): Likewise. (_initialize_ada_language): Remove symbol_list_obstack initialization. * ada-exp.y (block_lookup): Make sure "syms" gets xfree'ed. (write_var_or_type, write_name_assoc): Likewise. Tested on x86_64-linux.
2017-12-01 21:45:30 +01:00
const struct block *result = NULL;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
if (raw_name[0] == '\'')
{
raw_name += 1;
name = raw_name;
}
else
name = ada_encode (raw_name);
nsyms = ada_lookup_symbol_list (name, context, VAR_DOMAIN, &syms);
(Ada) GDB crash printing expression with type casting One of our users reported that trying to print the following expression, caused GDB to SEGV: (gdb) print some_package.some_type (val) In this particular instance, the crash occurred inside ada_args_match because it is given a NULL "func", leading to the SEGV because of: struct type *func_type = SYMBOL_TYPE (func); This NULL symbol comes from a list of symbols which was given to ada_resolve_function (parameter called "syms") which then iterates over each of them to discard the ones that don't match the actuals: for (k = 0; k < nsyms; k += 1) { struct type *type = ada_check_typedef (SYMBOL_TYPE (syms[k].symbol)); if (ada_args_match (syms[k].symbol, args, nargs) && (fallback || return_match (type, context_type))) [...] } What's really interesting is that, when entering the block above for the first time, all entries in SYMS have a valid (non-NULL) symbol. However, once we return from the call to ada_check_typedef, the first entry of our SYMS table gets set to all zeros: (gdb) p syms[0] $2 = {symbol = 0x0, block = 0x0} Hence the call to ada_args_match with a NULL symbol, and the ensuing SEGV. To find out why this happen, we need to step back a little and look at how syms was allocated. This list of symbols comes from a symbol lookup, which means ada_lookup_symbol_list_worker. We have our first hint when we look at the function's documentation and see: This vector is transient---good only to the next call of ada_lookup_symbol_list. Implementation-wise, this is done by using a static global obstack, which we just re-initialize each time ada_lookup_symbol_list_worker gets called: obstack_free (&symbol_list_obstack, NULL); obstack_init (&symbol_list_obstack); This property was probably established in order to facilitate the use of the returned vector, since the users of that function would not have to worry about releasing that memory when no longer needed. However, I found during this investigation that it is all to easy to indirectly trigger another symbol lookup while still using the results of a previous lookup. In our particular case, there is the call to ada_check_typedef, which leads to check_typedef. As it happens, my first symbol had a type which was a typedef to a stub type, so check_typedef calls lookup_symbol to find the non-stub version. This in turn eventually leads us back to ada_lookup_symbol_list_worker, where the first thing it does is free the memory area when our list of symbols have been residing and then recreates a new one. in other words, SYMS then becomes a dangling pointer! This patch fixes the issue by having ada_lookup_symbol_list_worker return a copy of the list of symbols, with the responsibility of deallocating that list now transfered to the users of that list. More generally speaking, it is absolutely amazing that we haven't seen consequences of this issue before. This can happen fairly frequently. For instance, I found that ada-exp.y::write_var_or_type calls ada_lookup_symbol_list, and then, while processing that list, calls select_possible_type_sym, which leads to ada_prefer_type, eventually leading to ada_check_typedef again (via eg. ada_is_array_descriptor_type). Even more amazing is the fact that, while I was able to produce multiple scenarios where the corruption occurs, none of them leads to incorrect behavior at the user level. In other words, it requires a very precise set of conditions for the corruption to become user-visible, and despite having a megalarge program where the crash occured, using that as a template for creating a reproducer did not work (pb goes away). This is why this patch does not come with a reproducer. On the other hand, this should not be a problem in terms of testing coverage, as the changes are made in common areas which, at least for the most part, are routinely exercised during testing. gdb/ChangeLog: * ada-lang.c (symbol_list_obstack): Delete. (resolve_subexp): Make sure "candidates" gets xfree'ed. (ada_lookup_symbol_list_worker): Remove the limitation that the result is only good until the next call, now making it the responsibility of the caller to free the result when no longer needed. Adjust the function's intro comment accordingly. (ada_lookup_symbol_list): Adjust the function's intro comment. (ada_iterate_over_symbols): Make sure "results" gets xfree'ed. (ada_lookup_encoded_symbol, get_var_value): Likewise. (_initialize_ada_language): Remove symbol_list_obstack initialization. * ada-exp.y (block_lookup): Make sure "syms" gets xfree'ed. (write_var_or_type, write_name_assoc): Likewise. Tested on x86_64-linux.
2017-12-01 21:45:30 +01:00
if (context == NULL
Replace the block_found global with explicit data-flow As Pedro suggested on gdb-patches@ (see https://sourceware.org/ml/gdb-patches/2015-05/msg00714.html), this change makes symbol lookup functions return a structure that includes both the symbol found and the block in which it was found. This makes it possible to get rid of the block_found global variable and thus makes block hunting explicit. gdb/ * ada-exp.y (write_object_renaming): Replace struct ada_symbol_info with struct block_symbol. Update field references accordingly. (block_lookup, select_possible_type_sym): Likewise. (find_primitive_type): Likewise. Also update call to ada_lookup_symbol to extract the symbol itself. (write_var_or_type, write_name_assoc): Likewise. * ada-lang.h (struct ada_symbol_info): Remove. (ada_lookup_symbol_list): Replace struct ada_symbol_info with struct block_symbol. (ada_lookup_encoded_symbol, user_select_syms): Likewise. (ada_lookup_symbol): Return struct block_symbol instead of a mere symbol. * ada-lang.c (defns_collected): Replace struct ada_symbol_info with struct block_symbol. (resolve_subexp, ada_resolve_function, sort_choices, user_select_syms, is_nonfunction, add_defn_to_vec, num_defns_collected, defns_collected, symbols_are_identical_enums, remove_extra_symbols, remove_irrelevant_renamings, add_lookup_symbol_list_worker, ada_lookup_symbol_list, ada_iterate_over_symbols, ada_lookup_encoded_symbol, get_var_value): Likewise. (ada_lookup_symbol): Return a block_symbol instead of a mere symbol. Replace struct ada_symbol_info with struct block_symbol. (ada_lookup_symbol_nonlocal): Likewise. (standard_lookup): Make block passing explicit through lookup_symbol_in_language. * ada-tasks.c (get_tcb_types_info): Update the calls to lookup_symbol_in_language to extract the mere symbol out of the returned value. (ada_tasks_inferior_data_sniffer): Likewise. * ax-gdb.c (gen_static_field): Likewise for the call to lookup_symbol. (gen_maybe_namespace_elt): Deal with struct symbol_in_block from lookup functions. (gen_expr): Likewise. * c-exp.y: Likewise. Remove uses of block_found. (lex_one_token, classify_inner_name, c_print_token): Likewise. (classify_name): Likewise. Rename the "sym" local variable to "bsym". * c-valprint.c (print_unpacked_pointer): Likewise. * compile/compile-c-symbols.c (convert_symbol_sym): Promote the "sym" parameter from struct symbol * to struct block_symbol. Use it to remove uses of block_found. Deal with struct symbol_in_block from lookup functions. (gcc_convert_symbol): Likewise. Update the call to convert_symbol_sym. * compile/compile-object-load.c (compile_object_load): Deal with struct symbol_in_block from lookup functions. * cp-namespace.c (cp_lookup_nested_symbol_1, cp_lookup_nested_symbol, cp_lookup_bare_symbol, cp_search_static_and_baseclasses, cp_lookup_symbol_in_namespace, cp_lookup_symbol_via_imports, cp_lookup_symbol_imports_or_template, cp_lookup_symbol_via_all_imports, cp_lookup_symbol_namespace, lookup_namespace_scope, cp_lookup_nonlocal, find_symbol_in_baseclass): Return struct symbol_in_block instead of mere symbols and deal with struct symbol_in_block from lookup functions. * cp-support.c (inspect_type, replace_typedefs, cp_lookup_rtti_type): Deal with struct symbol_in_block from lookup functions. * cp-support.h (cp_lookup_symbol_nonlocal, cp_lookup_symbol_from_namespace, cp_lookup_symbol_imports_or_template, cp_lookup_nested_symbol): Return struct symbol_in_block instead of mere symbols. * d-exp.y (d_type_from_name, d_module_from_name, push_variable, push_module_name): Deal with struct symbol_in_block from lookup functions. Remove uses of block_found. * eval.c (evaluate_subexp_standard): Update call to cp_lookup_symbol_namespace. * f-exp.y: Deal with struct symbol_in_block from lookup functions. Remove uses of block_found. (yylex): Likewise. * gdbtypes.c (lookup_typename, lookup_struct, lookup_union, lookup_enum, lookup_template_type, check_typedef): Deal with struct symbol_in_block from lookup functions. * guile/scm-frame.c (gdbscm_frame_read_var): Likewise. * guile/scm-symbol.c (gdbscm_lookup_symbol): Likewise. (gdbscm_lookup_global_symbol): Likewise. * gnu-v3-abi.c (gnuv3_get_typeid_type): Likewise. * go-exp.y: Likewise. Remove uses of block_found. (package_name_p, classify_packaged_name, classify_name): Likewise. * infrun.c (insert_exception_resume_breakpoint): Likewise. * jv-exp.y (push_variable): Likewise. * jv-lang.c (java_lookup_class, get_java_object_type): Likewise. * language.c (language_bool_type): Likewise. * language.h (struct language_defn): Update la_lookup_symbol_nonlocal to return a struct symbol_in_block rather than a mere symbol. * linespec.c (find_label_symbols): Deal with struct symbol_in_block from lookup functions. * m2-exp.y: Likewise. Remove uses of block_found. (yylex): Likewise. * mi/mi-cmd-stack.c (list_args_or_locals): Likewise. * objc-lang.c (lookup_struct_typedef, find_imps): Likewise. * p-exp.y: Likewise. Remove uses of block_found. (yylex): Likewise. * p-valprint.c (pascal_val_print): Likewise. * parse.c (write_dollar_variable): Likewise. Remove uses of block_found. * parser-defs.h (struct symtoken): Turn the SYM field into a struct symbol_in_block. * printcmd.c (address_info): Deal with struct symbol_in_block from lookup functions. * python/py-frame.c (frapy_read_var): Likewise. * python/py-symbol.c (gdbpy_lookup_symbol, gdbpy_lookup_global_symbol): Likewise. * skip.c (skip_function_command): Likewise. * solib-darwin.c (darwin_lookup_lib_symbol): Return a struct symbol_in_block instead of a mere symbol. * solib-spu.c (spu_lookup_lib_symbol): Likewise. * solib-svr4.c (elf_lookup_lib_symbol): Likewise. * solib.c (solib_global_lookup): Likewise. * solist.h (solib_global_lookup): Likewise. (struct target_so_ops): Update lookup_lib_global_symbol to return a struct symbol_in_block rather than a mere symbol. * source.c (select_source_symtab): Deal with struct symbol_in_block from lookup functions. * stack.c (print_frame_args, iterate_over_block_arg_vars): Likewise. * symfile.c (set_initial_language): Likewise. * symtab.c (SYMBOL_LOOKUP_FAILED): Turn into a struct symbol_in_block. (SYMBOL_LOOKUP_FAILED_P): New predicate as a macro. (struct symbol_cache_slot): Turn the FOUND field into a struct symbol_in_block. (block_found): Remove. (eq_symbol_entry): Update to deal with struct symbol_in_block in cache slots. (symbol_cache_lookup): Return a struct symbol_in_block rather than a mere symbol. (symbol_cache_mark_found): Add a BLOCK parameter to fill appropriately the cache slots. Update callers. (symbol_cache_dump): Update cache slots handling to the type change. (lookup_symbol_in_language, lookup_symbol, lookup_language_this, lookup_symbol_aux, lookup_local_symbol, lookup_symbol_in_objfile, lookup_global_symbol_from_objfile, lookup_symbol_in_objfile_symtabs, lookup_symbol_in_objfile_from_linkage_name, lookup_symbol_via_quick_fns, basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block, lookup_static_symbol, lookup_global_symbol): Return a struct symbol_in_block rather than a mere symbol. Deal with struct symbol_in_block from other lookup functions. Remove uses of block_found. (lookup_symbol_in_block): Remove uses of block_found. (struct global_sym_lookup_data): Turn the RESULT field into a struct symbol_in_block. (lookup_symbol_global_iterator_cb): Update references to the RESULT field. (search_symbols): Deal with struct symbol_in_block from lookup functions. * symtab.h (struct symbol_in_block): New structure. (block_found): Remove. (lookup_symbol_in_language, lookup_symbol, basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block, looku_static_symbol, lookup_global_symbol, lookup_symbol_in_block, lookup_language_this, lookup_global_symbol_from_objfile): Return a struct symbol_in_block rather than just a mere symbol. Update comments to remove mentions of block_found. * valops.c (find_function_in_inferior, value_struct_elt_for_reference, value_maybe_namespace_elt, value_of_this): Deal with struct symbol_in_block from lookup functions. * value.c (value_static_field, value_fn_field): Likewise.
2015-07-21 17:02:15 +02:00
&& (nsyms == 0 || SYMBOL_CLASS (syms[0].symbol) != LOC_BLOCK))
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
symtab = lookup_symtab (name);
else
symtab = NULL;
if (symtab != NULL)
(Ada) GDB crash printing expression with type casting One of our users reported that trying to print the following expression, caused GDB to SEGV: (gdb) print some_package.some_type (val) In this particular instance, the crash occurred inside ada_args_match because it is given a NULL "func", leading to the SEGV because of: struct type *func_type = SYMBOL_TYPE (func); This NULL symbol comes from a list of symbols which was given to ada_resolve_function (parameter called "syms") which then iterates over each of them to discard the ones that don't match the actuals: for (k = 0; k < nsyms; k += 1) { struct type *type = ada_check_typedef (SYMBOL_TYPE (syms[k].symbol)); if (ada_args_match (syms[k].symbol, args, nargs) && (fallback || return_match (type, context_type))) [...] } What's really interesting is that, when entering the block above for the first time, all entries in SYMS have a valid (non-NULL) symbol. However, once we return from the call to ada_check_typedef, the first entry of our SYMS table gets set to all zeros: (gdb) p syms[0] $2 = {symbol = 0x0, block = 0x0} Hence the call to ada_args_match with a NULL symbol, and the ensuing SEGV. To find out why this happen, we need to step back a little and look at how syms was allocated. This list of symbols comes from a symbol lookup, which means ada_lookup_symbol_list_worker. We have our first hint when we look at the function's documentation and see: This vector is transient---good only to the next call of ada_lookup_symbol_list. Implementation-wise, this is done by using a static global obstack, which we just re-initialize each time ada_lookup_symbol_list_worker gets called: obstack_free (&symbol_list_obstack, NULL); obstack_init (&symbol_list_obstack); This property was probably established in order to facilitate the use of the returned vector, since the users of that function would not have to worry about releasing that memory when no longer needed. However, I found during this investigation that it is all to easy to indirectly trigger another symbol lookup while still using the results of a previous lookup. In our particular case, there is the call to ada_check_typedef, which leads to check_typedef. As it happens, my first symbol had a type which was a typedef to a stub type, so check_typedef calls lookup_symbol to find the non-stub version. This in turn eventually leads us back to ada_lookup_symbol_list_worker, where the first thing it does is free the memory area when our list of symbols have been residing and then recreates a new one. in other words, SYMS then becomes a dangling pointer! This patch fixes the issue by having ada_lookup_symbol_list_worker return a copy of the list of symbols, with the responsibility of deallocating that list now transfered to the users of that list. More generally speaking, it is absolutely amazing that we haven't seen consequences of this issue before. This can happen fairly frequently. For instance, I found that ada-exp.y::write_var_or_type calls ada_lookup_symbol_list, and then, while processing that list, calls select_possible_type_sym, which leads to ada_prefer_type, eventually leading to ada_check_typedef again (via eg. ada_is_array_descriptor_type). Even more amazing is the fact that, while I was able to produce multiple scenarios where the corruption occurs, none of them leads to incorrect behavior at the user level. In other words, it requires a very precise set of conditions for the corruption to become user-visible, and despite having a megalarge program where the crash occured, using that as a template for creating a reproducer did not work (pb goes away). This is why this patch does not come with a reproducer. On the other hand, this should not be a problem in terms of testing coverage, as the changes are made in common areas which, at least for the most part, are routinely exercised during testing. gdb/ChangeLog: * ada-lang.c (symbol_list_obstack): Delete. (resolve_subexp): Make sure "candidates" gets xfree'ed. (ada_lookup_symbol_list_worker): Remove the limitation that the result is only good until the next call, now making it the responsibility of the caller to free the result when no longer needed. Adjust the function's intro comment accordingly. (ada_lookup_symbol_list): Adjust the function's intro comment. (ada_iterate_over_symbols): Make sure "results" gets xfree'ed. (ada_lookup_encoded_symbol, get_var_value): Likewise. (_initialize_ada_language): Remove symbol_list_obstack initialization. * ada-exp.y (block_lookup): Make sure "syms" gets xfree'ed. (write_var_or_type, write_name_assoc): Likewise. Tested on x86_64-linux.
2017-12-01 21:45:30 +01:00
result = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (symtab), STATIC_BLOCK);
Replace the block_found global with explicit data-flow As Pedro suggested on gdb-patches@ (see https://sourceware.org/ml/gdb-patches/2015-05/msg00714.html), this change makes symbol lookup functions return a structure that includes both the symbol found and the block in which it was found. This makes it possible to get rid of the block_found global variable and thus makes block hunting explicit. gdb/ * ada-exp.y (write_object_renaming): Replace struct ada_symbol_info with struct block_symbol. Update field references accordingly. (block_lookup, select_possible_type_sym): Likewise. (find_primitive_type): Likewise. Also update call to ada_lookup_symbol to extract the symbol itself. (write_var_or_type, write_name_assoc): Likewise. * ada-lang.h (struct ada_symbol_info): Remove. (ada_lookup_symbol_list): Replace struct ada_symbol_info with struct block_symbol. (ada_lookup_encoded_symbol, user_select_syms): Likewise. (ada_lookup_symbol): Return struct block_symbol instead of a mere symbol. * ada-lang.c (defns_collected): Replace struct ada_symbol_info with struct block_symbol. (resolve_subexp, ada_resolve_function, sort_choices, user_select_syms, is_nonfunction, add_defn_to_vec, num_defns_collected, defns_collected, symbols_are_identical_enums, remove_extra_symbols, remove_irrelevant_renamings, add_lookup_symbol_list_worker, ada_lookup_symbol_list, ada_iterate_over_symbols, ada_lookup_encoded_symbol, get_var_value): Likewise. (ada_lookup_symbol): Return a block_symbol instead of a mere symbol. Replace struct ada_symbol_info with struct block_symbol. (ada_lookup_symbol_nonlocal): Likewise. (standard_lookup): Make block passing explicit through lookup_symbol_in_language. * ada-tasks.c (get_tcb_types_info): Update the calls to lookup_symbol_in_language to extract the mere symbol out of the returned value. (ada_tasks_inferior_data_sniffer): Likewise. * ax-gdb.c (gen_static_field): Likewise for the call to lookup_symbol. (gen_maybe_namespace_elt): Deal with struct symbol_in_block from lookup functions. (gen_expr): Likewise. * c-exp.y: Likewise. Remove uses of block_found. (lex_one_token, classify_inner_name, c_print_token): Likewise. (classify_name): Likewise. Rename the "sym" local variable to "bsym". * c-valprint.c (print_unpacked_pointer): Likewise. * compile/compile-c-symbols.c (convert_symbol_sym): Promote the "sym" parameter from struct symbol * to struct block_symbol. Use it to remove uses of block_found. Deal with struct symbol_in_block from lookup functions. (gcc_convert_symbol): Likewise. Update the call to convert_symbol_sym. * compile/compile-object-load.c (compile_object_load): Deal with struct symbol_in_block from lookup functions. * cp-namespace.c (cp_lookup_nested_symbol_1, cp_lookup_nested_symbol, cp_lookup_bare_symbol, cp_search_static_and_baseclasses, cp_lookup_symbol_in_namespace, cp_lookup_symbol_via_imports, cp_lookup_symbol_imports_or_template, cp_lookup_symbol_via_all_imports, cp_lookup_symbol_namespace, lookup_namespace_scope, cp_lookup_nonlocal, find_symbol_in_baseclass): Return struct symbol_in_block instead of mere symbols and deal with struct symbol_in_block from lookup functions. * cp-support.c (inspect_type, replace_typedefs, cp_lookup_rtti_type): Deal with struct symbol_in_block from lookup functions. * cp-support.h (cp_lookup_symbol_nonlocal, cp_lookup_symbol_from_namespace, cp_lookup_symbol_imports_or_template, cp_lookup_nested_symbol): Return struct symbol_in_block instead of mere symbols. * d-exp.y (d_type_from_name, d_module_from_name, push_variable, push_module_name): Deal with struct symbol_in_block from lookup functions. Remove uses of block_found. * eval.c (evaluate_subexp_standard): Update call to cp_lookup_symbol_namespace. * f-exp.y: Deal with struct symbol_in_block from lookup functions. Remove uses of block_found. (yylex): Likewise. * gdbtypes.c (lookup_typename, lookup_struct, lookup_union, lookup_enum, lookup_template_type, check_typedef): Deal with struct symbol_in_block from lookup functions. * guile/scm-frame.c (gdbscm_frame_read_var): Likewise. * guile/scm-symbol.c (gdbscm_lookup_symbol): Likewise. (gdbscm_lookup_global_symbol): Likewise. * gnu-v3-abi.c (gnuv3_get_typeid_type): Likewise. * go-exp.y: Likewise. Remove uses of block_found. (package_name_p, classify_packaged_name, classify_name): Likewise. * infrun.c (insert_exception_resume_breakpoint): Likewise. * jv-exp.y (push_variable): Likewise. * jv-lang.c (java_lookup_class, get_java_object_type): Likewise. * language.c (language_bool_type): Likewise. * language.h (struct language_defn): Update la_lookup_symbol_nonlocal to return a struct symbol_in_block rather than a mere symbol. * linespec.c (find_label_symbols): Deal with struct symbol_in_block from lookup functions. * m2-exp.y: Likewise. Remove uses of block_found. (yylex): Likewise. * mi/mi-cmd-stack.c (list_args_or_locals): Likewise. * objc-lang.c (lookup_struct_typedef, find_imps): Likewise. * p-exp.y: Likewise. Remove uses of block_found. (yylex): Likewise. * p-valprint.c (pascal_val_print): Likewise. * parse.c (write_dollar_variable): Likewise. Remove uses of block_found. * parser-defs.h (struct symtoken): Turn the SYM field into a struct symbol_in_block. * printcmd.c (address_info): Deal with struct symbol_in_block from lookup functions. * python/py-frame.c (frapy_read_var): Likewise. * python/py-symbol.c (gdbpy_lookup_symbol, gdbpy_lookup_global_symbol): Likewise. * skip.c (skip_function_command): Likewise. * solib-darwin.c (darwin_lookup_lib_symbol): Return a struct symbol_in_block instead of a mere symbol. * solib-spu.c (spu_lookup_lib_symbol): Likewise. * solib-svr4.c (elf_lookup_lib_symbol): Likewise. * solib.c (solib_global_lookup): Likewise. * solist.h (solib_global_lookup): Likewise. (struct target_so_ops): Update lookup_lib_global_symbol to return a struct symbol_in_block rather than a mere symbol. * source.c (select_source_symtab): Deal with struct symbol_in_block from lookup functions. * stack.c (print_frame_args, iterate_over_block_arg_vars): Likewise. * symfile.c (set_initial_language): Likewise. * symtab.c (SYMBOL_LOOKUP_FAILED): Turn into a struct symbol_in_block. (SYMBOL_LOOKUP_FAILED_P): New predicate as a macro. (struct symbol_cache_slot): Turn the FOUND field into a struct symbol_in_block. (block_found): Remove. (eq_symbol_entry): Update to deal with struct symbol_in_block in cache slots. (symbol_cache_lookup): Return a struct symbol_in_block rather than a mere symbol. (symbol_cache_mark_found): Add a BLOCK parameter to fill appropriately the cache slots. Update callers. (symbol_cache_dump): Update cache slots handling to the type change. (lookup_symbol_in_language, lookup_symbol, lookup_language_this, lookup_symbol_aux, lookup_local_symbol, lookup_symbol_in_objfile, lookup_global_symbol_from_objfile, lookup_symbol_in_objfile_symtabs, lookup_symbol_in_objfile_from_linkage_name, lookup_symbol_via_quick_fns, basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block, lookup_static_symbol, lookup_global_symbol): Return a struct symbol_in_block rather than a mere symbol. Deal with struct symbol_in_block from other lookup functions. Remove uses of block_found. (lookup_symbol_in_block): Remove uses of block_found. (struct global_sym_lookup_data): Turn the RESULT field into a struct symbol_in_block. (lookup_symbol_global_iterator_cb): Update references to the RESULT field. (search_symbols): Deal with struct symbol_in_block from lookup functions. * symtab.h (struct symbol_in_block): New structure. (block_found): Remove. (lookup_symbol_in_language, lookup_symbol, basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block, looku_static_symbol, lookup_global_symbol, lookup_symbol_in_block, lookup_language_this, lookup_global_symbol_from_objfile): Return a struct symbol_in_block rather than just a mere symbol. Update comments to remove mentions of block_found. * valops.c (find_function_in_inferior, value_struct_elt_for_reference, value_maybe_namespace_elt, value_of_this): Deal with struct symbol_in_block from lookup functions. * value.c (value_static_field, value_fn_field): Likewise.
2015-07-21 17:02:15 +02:00
else if (nsyms == 0 || SYMBOL_CLASS (syms[0].symbol) != LOC_BLOCK)
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
{
if (context == NULL)
error (_("No file or function \"%s\"."), raw_name);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
else
error (_("No function \"%s\" in specified context."), raw_name);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
}
else
{
if (nsyms > 1)
warning (_("Function name \"%s\" ambiguous here"), raw_name);
(Ada) GDB crash printing expression with type casting One of our users reported that trying to print the following expression, caused GDB to SEGV: (gdb) print some_package.some_type (val) In this particular instance, the crash occurred inside ada_args_match because it is given a NULL "func", leading to the SEGV because of: struct type *func_type = SYMBOL_TYPE (func); This NULL symbol comes from a list of symbols which was given to ada_resolve_function (parameter called "syms") which then iterates over each of them to discard the ones that don't match the actuals: for (k = 0; k < nsyms; k += 1) { struct type *type = ada_check_typedef (SYMBOL_TYPE (syms[k].symbol)); if (ada_args_match (syms[k].symbol, args, nargs) && (fallback || return_match (type, context_type))) [...] } What's really interesting is that, when entering the block above for the first time, all entries in SYMS have a valid (non-NULL) symbol. However, once we return from the call to ada_check_typedef, the first entry of our SYMS table gets set to all zeros: (gdb) p syms[0] $2 = {symbol = 0x0, block = 0x0} Hence the call to ada_args_match with a NULL symbol, and the ensuing SEGV. To find out why this happen, we need to step back a little and look at how syms was allocated. This list of symbols comes from a symbol lookup, which means ada_lookup_symbol_list_worker. We have our first hint when we look at the function's documentation and see: This vector is transient---good only to the next call of ada_lookup_symbol_list. Implementation-wise, this is done by using a static global obstack, which we just re-initialize each time ada_lookup_symbol_list_worker gets called: obstack_free (&symbol_list_obstack, NULL); obstack_init (&symbol_list_obstack); This property was probably established in order to facilitate the use of the returned vector, since the users of that function would not have to worry about releasing that memory when no longer needed. However, I found during this investigation that it is all to easy to indirectly trigger another symbol lookup while still using the results of a previous lookup. In our particular case, there is the call to ada_check_typedef, which leads to check_typedef. As it happens, my first symbol had a type which was a typedef to a stub type, so check_typedef calls lookup_symbol to find the non-stub version. This in turn eventually leads us back to ada_lookup_symbol_list_worker, where the first thing it does is free the memory area when our list of symbols have been residing and then recreates a new one. in other words, SYMS then becomes a dangling pointer! This patch fixes the issue by having ada_lookup_symbol_list_worker return a copy of the list of symbols, with the responsibility of deallocating that list now transfered to the users of that list. More generally speaking, it is absolutely amazing that we haven't seen consequences of this issue before. This can happen fairly frequently. For instance, I found that ada-exp.y::write_var_or_type calls ada_lookup_symbol_list, and then, while processing that list, calls select_possible_type_sym, which leads to ada_prefer_type, eventually leading to ada_check_typedef again (via eg. ada_is_array_descriptor_type). Even more amazing is the fact that, while I was able to produce multiple scenarios where the corruption occurs, none of them leads to incorrect behavior at the user level. In other words, it requires a very precise set of conditions for the corruption to become user-visible, and despite having a megalarge program where the crash occured, using that as a template for creating a reproducer did not work (pb goes away). This is why this patch does not come with a reproducer. On the other hand, this should not be a problem in terms of testing coverage, as the changes are made in common areas which, at least for the most part, are routinely exercised during testing. gdb/ChangeLog: * ada-lang.c (symbol_list_obstack): Delete. (resolve_subexp): Make sure "candidates" gets xfree'ed. (ada_lookup_symbol_list_worker): Remove the limitation that the result is only good until the next call, now making it the responsibility of the caller to free the result when no longer needed. Adjust the function's intro comment accordingly. (ada_lookup_symbol_list): Adjust the function's intro comment. (ada_iterate_over_symbols): Make sure "results" gets xfree'ed. (ada_lookup_encoded_symbol, get_var_value): Likewise. (_initialize_ada_language): Remove symbol_list_obstack initialization. * ada-exp.y (block_lookup): Make sure "syms" gets xfree'ed. (write_var_or_type, write_name_assoc): Likewise. Tested on x86_64-linux.
2017-12-01 21:45:30 +01:00
result = SYMBOL_BLOCK_VALUE (syms[0].symbol);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
}
(Ada) GDB crash printing expression with type casting One of our users reported that trying to print the following expression, caused GDB to SEGV: (gdb) print some_package.some_type (val) In this particular instance, the crash occurred inside ada_args_match because it is given a NULL "func", leading to the SEGV because of: struct type *func_type = SYMBOL_TYPE (func); This NULL symbol comes from a list of symbols which was given to ada_resolve_function (parameter called "syms") which then iterates over each of them to discard the ones that don't match the actuals: for (k = 0; k < nsyms; k += 1) { struct type *type = ada_check_typedef (SYMBOL_TYPE (syms[k].symbol)); if (ada_args_match (syms[k].symbol, args, nargs) && (fallback || return_match (type, context_type))) [...] } What's really interesting is that, when entering the block above for the first time, all entries in SYMS have a valid (non-NULL) symbol. However, once we return from the call to ada_check_typedef, the first entry of our SYMS table gets set to all zeros: (gdb) p syms[0] $2 = {symbol = 0x0, block = 0x0} Hence the call to ada_args_match with a NULL symbol, and the ensuing SEGV. To find out why this happen, we need to step back a little and look at how syms was allocated. This list of symbols comes from a symbol lookup, which means ada_lookup_symbol_list_worker. We have our first hint when we look at the function's documentation and see: This vector is transient---good only to the next call of ada_lookup_symbol_list. Implementation-wise, this is done by using a static global obstack, which we just re-initialize each time ada_lookup_symbol_list_worker gets called: obstack_free (&symbol_list_obstack, NULL); obstack_init (&symbol_list_obstack); This property was probably established in order to facilitate the use of the returned vector, since the users of that function would not have to worry about releasing that memory when no longer needed. However, I found during this investigation that it is all to easy to indirectly trigger another symbol lookup while still using the results of a previous lookup. In our particular case, there is the call to ada_check_typedef, which leads to check_typedef. As it happens, my first symbol had a type which was a typedef to a stub type, so check_typedef calls lookup_symbol to find the non-stub version. This in turn eventually leads us back to ada_lookup_symbol_list_worker, where the first thing it does is free the memory area when our list of symbols have been residing and then recreates a new one. in other words, SYMS then becomes a dangling pointer! This patch fixes the issue by having ada_lookup_symbol_list_worker return a copy of the list of symbols, with the responsibility of deallocating that list now transfered to the users of that list. More generally speaking, it is absolutely amazing that we haven't seen consequences of this issue before. This can happen fairly frequently. For instance, I found that ada-exp.y::write_var_or_type calls ada_lookup_symbol_list, and then, while processing that list, calls select_possible_type_sym, which leads to ada_prefer_type, eventually leading to ada_check_typedef again (via eg. ada_is_array_descriptor_type). Even more amazing is the fact that, while I was able to produce multiple scenarios where the corruption occurs, none of them leads to incorrect behavior at the user level. In other words, it requires a very precise set of conditions for the corruption to become user-visible, and despite having a megalarge program where the crash occured, using that as a template for creating a reproducer did not work (pb goes away). This is why this patch does not come with a reproducer. On the other hand, this should not be a problem in terms of testing coverage, as the changes are made in common areas which, at least for the most part, are routinely exercised during testing. gdb/ChangeLog: * ada-lang.c (symbol_list_obstack): Delete. (resolve_subexp): Make sure "candidates" gets xfree'ed. (ada_lookup_symbol_list_worker): Remove the limitation that the result is only good until the next call, now making it the responsibility of the caller to free the result when no longer needed. Adjust the function's intro comment accordingly. (ada_lookup_symbol_list): Adjust the function's intro comment. (ada_iterate_over_symbols): Make sure "results" gets xfree'ed. (ada_lookup_encoded_symbol, get_var_value): Likewise. (_initialize_ada_language): Remove symbol_list_obstack initialization. * ada-exp.y (block_lookup): Make sure "syms" gets xfree'ed. (write_var_or_type, write_name_assoc): Likewise. Tested on x86_64-linux.
2017-12-01 21:45:30 +01:00
return result;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
}
static struct symbol*
select_possible_type_sym (const std::vector<struct block_symbol> &syms)
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
{
int i;
int preferred_index;
struct type *preferred_type;
preferred_index = -1; preferred_type = NULL;
for (i = 0; i < syms.size (); i += 1)
Replace the block_found global with explicit data-flow As Pedro suggested on gdb-patches@ (see https://sourceware.org/ml/gdb-patches/2015-05/msg00714.html), this change makes symbol lookup functions return a structure that includes both the symbol found and the block in which it was found. This makes it possible to get rid of the block_found global variable and thus makes block hunting explicit. gdb/ * ada-exp.y (write_object_renaming): Replace struct ada_symbol_info with struct block_symbol. Update field references accordingly. (block_lookup, select_possible_type_sym): Likewise. (find_primitive_type): Likewise. Also update call to ada_lookup_symbol to extract the symbol itself. (write_var_or_type, write_name_assoc): Likewise. * ada-lang.h (struct ada_symbol_info): Remove. (ada_lookup_symbol_list): Replace struct ada_symbol_info with struct block_symbol. (ada_lookup_encoded_symbol, user_select_syms): Likewise. (ada_lookup_symbol): Return struct block_symbol instead of a mere symbol. * ada-lang.c (defns_collected): Replace struct ada_symbol_info with struct block_symbol. (resolve_subexp, ada_resolve_function, sort_choices, user_select_syms, is_nonfunction, add_defn_to_vec, num_defns_collected, defns_collected, symbols_are_identical_enums, remove_extra_symbols, remove_irrelevant_renamings, add_lookup_symbol_list_worker, ada_lookup_symbol_list, ada_iterate_over_symbols, ada_lookup_encoded_symbol, get_var_value): Likewise. (ada_lookup_symbol): Return a block_symbol instead of a mere symbol. Replace struct ada_symbol_info with struct block_symbol. (ada_lookup_symbol_nonlocal): Likewise. (standard_lookup): Make block passing explicit through lookup_symbol_in_language. * ada-tasks.c (get_tcb_types_info): Update the calls to lookup_symbol_in_language to extract the mere symbol out of the returned value. (ada_tasks_inferior_data_sniffer): Likewise. * ax-gdb.c (gen_static_field): Likewise for the call to lookup_symbol. (gen_maybe_namespace_elt): Deal with struct symbol_in_block from lookup functions. (gen_expr): Likewise. * c-exp.y: Likewise. Remove uses of block_found. (lex_one_token, classify_inner_name, c_print_token): Likewise. (classify_name): Likewise. Rename the "sym" local variable to "bsym". * c-valprint.c (print_unpacked_pointer): Likewise. * compile/compile-c-symbols.c (convert_symbol_sym): Promote the "sym" parameter from struct symbol * to struct block_symbol. Use it to remove uses of block_found. Deal with struct symbol_in_block from lookup functions. (gcc_convert_symbol): Likewise. Update the call to convert_symbol_sym. * compile/compile-object-load.c (compile_object_load): Deal with struct symbol_in_block from lookup functions. * cp-namespace.c (cp_lookup_nested_symbol_1, cp_lookup_nested_symbol, cp_lookup_bare_symbol, cp_search_static_and_baseclasses, cp_lookup_symbol_in_namespace, cp_lookup_symbol_via_imports, cp_lookup_symbol_imports_or_template, cp_lookup_symbol_via_all_imports, cp_lookup_symbol_namespace, lookup_namespace_scope, cp_lookup_nonlocal, find_symbol_in_baseclass): Return struct symbol_in_block instead of mere symbols and deal with struct symbol_in_block from lookup functions. * cp-support.c (inspect_type, replace_typedefs, cp_lookup_rtti_type): Deal with struct symbol_in_block from lookup functions. * cp-support.h (cp_lookup_symbol_nonlocal, cp_lookup_symbol_from_namespace, cp_lookup_symbol_imports_or_template, cp_lookup_nested_symbol): Return struct symbol_in_block instead of mere symbols. * d-exp.y (d_type_from_name, d_module_from_name, push_variable, push_module_name): Deal with struct symbol_in_block from lookup functions. Remove uses of block_found. * eval.c (evaluate_subexp_standard): Update call to cp_lookup_symbol_namespace. * f-exp.y: Deal with struct symbol_in_block from lookup functions. Remove uses of block_found. (yylex): Likewise. * gdbtypes.c (lookup_typename, lookup_struct, lookup_union, lookup_enum, lookup_template_type, check_typedef): Deal with struct symbol_in_block from lookup functions. * guile/scm-frame.c (gdbscm_frame_read_var): Likewise. * guile/scm-symbol.c (gdbscm_lookup_symbol): Likewise. (gdbscm_lookup_global_symbol): Likewise. * gnu-v3-abi.c (gnuv3_get_typeid_type): Likewise. * go-exp.y: Likewise. Remove uses of block_found. (package_name_p, classify_packaged_name, classify_name): Likewise. * infrun.c (insert_exception_resume_breakpoint): Likewise. * jv-exp.y (push_variable): Likewise. * jv-lang.c (java_lookup_class, get_java_object_type): Likewise. * language.c (language_bool_type): Likewise. * language.h (struct language_defn): Update la_lookup_symbol_nonlocal to return a struct symbol_in_block rather than a mere symbol. * linespec.c (find_label_symbols): Deal with struct symbol_in_block from lookup functions. * m2-exp.y: Likewise. Remove uses of block_found. (yylex): Likewise. * mi/mi-cmd-stack.c (list_args_or_locals): Likewise. * objc-lang.c (lookup_struct_typedef, find_imps): Likewise. * p-exp.y: Likewise. Remove uses of block_found. (yylex): Likewise. * p-valprint.c (pascal_val_print): Likewise. * parse.c (write_dollar_variable): Likewise. Remove uses of block_found. * parser-defs.h (struct symtoken): Turn the SYM field into a struct symbol_in_block. * printcmd.c (address_info): Deal with struct symbol_in_block from lookup functions. * python/py-frame.c (frapy_read_var): Likewise. * python/py-symbol.c (gdbpy_lookup_symbol, gdbpy_lookup_global_symbol): Likewise. * skip.c (skip_function_command): Likewise. * solib-darwin.c (darwin_lookup_lib_symbol): Return a struct symbol_in_block instead of a mere symbol. * solib-spu.c (spu_lookup_lib_symbol): Likewise. * solib-svr4.c (elf_lookup_lib_symbol): Likewise. * solib.c (solib_global_lookup): Likewise. * solist.h (solib_global_lookup): Likewise. (struct target_so_ops): Update lookup_lib_global_symbol to return a struct symbol_in_block rather than a mere symbol. * source.c (select_source_symtab): Deal with struct symbol_in_block from lookup functions. * stack.c (print_frame_args, iterate_over_block_arg_vars): Likewise. * symfile.c (set_initial_language): Likewise. * symtab.c (SYMBOL_LOOKUP_FAILED): Turn into a struct symbol_in_block. (SYMBOL_LOOKUP_FAILED_P): New predicate as a macro. (struct symbol_cache_slot): Turn the FOUND field into a struct symbol_in_block. (block_found): Remove. (eq_symbol_entry): Update to deal with struct symbol_in_block in cache slots. (symbol_cache_lookup): Return a struct symbol_in_block rather than a mere symbol. (symbol_cache_mark_found): Add a BLOCK parameter to fill appropriately the cache slots. Update callers. (symbol_cache_dump): Update cache slots handling to the type change. (lookup_symbol_in_language, lookup_symbol, lookup_language_this, lookup_symbol_aux, lookup_local_symbol, lookup_symbol_in_objfile, lookup_global_symbol_from_objfile, lookup_symbol_in_objfile_symtabs, lookup_symbol_in_objfile_from_linkage_name, lookup_symbol_via_quick_fns, basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block, lookup_static_symbol, lookup_global_symbol): Return a struct symbol_in_block rather than a mere symbol. Deal with struct symbol_in_block from other lookup functions. Remove uses of block_found. (lookup_symbol_in_block): Remove uses of block_found. (struct global_sym_lookup_data): Turn the RESULT field into a struct symbol_in_block. (lookup_symbol_global_iterator_cb): Update references to the RESULT field. (search_symbols): Deal with struct symbol_in_block from lookup functions. * symtab.h (struct symbol_in_block): New structure. (block_found): Remove. (lookup_symbol_in_language, lookup_symbol, basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block, looku_static_symbol, lookup_global_symbol, lookup_symbol_in_block, lookup_language_this, lookup_global_symbol_from_objfile): Return a struct symbol_in_block rather than just a mere symbol. Update comments to remove mentions of block_found. * valops.c (find_function_in_inferior, value_struct_elt_for_reference, value_maybe_namespace_elt, value_of_this): Deal with struct symbol_in_block from lookup functions. * value.c (value_static_field, value_fn_field): Likewise.
2015-07-21 17:02:15 +02:00
switch (SYMBOL_CLASS (syms[i].symbol))
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
{
case LOC_TYPEDEF:
Replace the block_found global with explicit data-flow As Pedro suggested on gdb-patches@ (see https://sourceware.org/ml/gdb-patches/2015-05/msg00714.html), this change makes symbol lookup functions return a structure that includes both the symbol found and the block in which it was found. This makes it possible to get rid of the block_found global variable and thus makes block hunting explicit. gdb/ * ada-exp.y (write_object_renaming): Replace struct ada_symbol_info with struct block_symbol. Update field references accordingly. (block_lookup, select_possible_type_sym): Likewise. (find_primitive_type): Likewise. Also update call to ada_lookup_symbol to extract the symbol itself. (write_var_or_type, write_name_assoc): Likewise. * ada-lang.h (struct ada_symbol_info): Remove. (ada_lookup_symbol_list): Replace struct ada_symbol_info with struct block_symbol. (ada_lookup_encoded_symbol, user_select_syms): Likewise. (ada_lookup_symbol): Return struct block_symbol instead of a mere symbol. * ada-lang.c (defns_collected): Replace struct ada_symbol_info with struct block_symbol. (resolve_subexp, ada_resolve_function, sort_choices, user_select_syms, is_nonfunction, add_defn_to_vec, num_defns_collected, defns_collected, symbols_are_identical_enums, remove_extra_symbols, remove_irrelevant_renamings, add_lookup_symbol_list_worker, ada_lookup_symbol_list, ada_iterate_over_symbols, ada_lookup_encoded_symbol, get_var_value): Likewise. (ada_lookup_symbol): Return a block_symbol instead of a mere symbol. Replace struct ada_symbol_info with struct block_symbol. (ada_lookup_symbol_nonlocal): Likewise. (standard_lookup): Make block passing explicit through lookup_symbol_in_language. * ada-tasks.c (get_tcb_types_info): Update the calls to lookup_symbol_in_language to extract the mere symbol out of the returned value. (ada_tasks_inferior_data_sniffer): Likewise. * ax-gdb.c (gen_static_field): Likewise for the call to lookup_symbol. (gen_maybe_namespace_elt): Deal with struct symbol_in_block from lookup functions. (gen_expr): Likewise. * c-exp.y: Likewise. Remove uses of block_found. (lex_one_token, classify_inner_name, c_print_token): Likewise. (classify_name): Likewise. Rename the "sym" local variable to "bsym". * c-valprint.c (print_unpacked_pointer): Likewise. * compile/compile-c-symbols.c (convert_symbol_sym): Promote the "sym" parameter from struct symbol * to struct block_symbol. Use it to remove uses of block_found. Deal with struct symbol_in_block from lookup functions. (gcc_convert_symbol): Likewise. Update the call to convert_symbol_sym. * compile/compile-object-load.c (compile_object_load): Deal with struct symbol_in_block from lookup functions. * cp-namespace.c (cp_lookup_nested_symbol_1, cp_lookup_nested_symbol, cp_lookup_bare_symbol, cp_search_static_and_baseclasses, cp_lookup_symbol_in_namespace, cp_lookup_symbol_via_imports, cp_lookup_symbol_imports_or_template, cp_lookup_symbol_via_all_imports, cp_lookup_symbol_namespace, lookup_namespace_scope, cp_lookup_nonlocal, find_symbol_in_baseclass): Return struct symbol_in_block instead of mere symbols and deal with struct symbol_in_block from lookup functions. * cp-support.c (inspect_type, replace_typedefs, cp_lookup_rtti_type): Deal with struct symbol_in_block from lookup functions. * cp-support.h (cp_lookup_symbol_nonlocal, cp_lookup_symbol_from_namespace, cp_lookup_symbol_imports_or_template, cp_lookup_nested_symbol): Return struct symbol_in_block instead of mere symbols. * d-exp.y (d_type_from_name, d_module_from_name, push_variable, push_module_name): Deal with struct symbol_in_block from lookup functions. Remove uses of block_found. * eval.c (evaluate_subexp_standard): Update call to cp_lookup_symbol_namespace. * f-exp.y: Deal with struct symbol_in_block from lookup functions. Remove uses of block_found. (yylex): Likewise. * gdbtypes.c (lookup_typename, lookup_struct, lookup_union, lookup_enum, lookup_template_type, check_typedef): Deal with struct symbol_in_block from lookup functions. * guile/scm-frame.c (gdbscm_frame_read_var): Likewise. * guile/scm-symbol.c (gdbscm_lookup_symbol): Likewise. (gdbscm_lookup_global_symbol): Likewise. * gnu-v3-abi.c (gnuv3_get_typeid_type): Likewise. * go-exp.y: Likewise. Remove uses of block_found. (package_name_p, classify_packaged_name, classify_name): Likewise. * infrun.c (insert_exception_resume_breakpoint): Likewise. * jv-exp.y (push_variable): Likewise. * jv-lang.c (java_lookup_class, get_java_object_type): Likewise. * language.c (language_bool_type): Likewise. * language.h (struct language_defn): Update la_lookup_symbol_nonlocal to return a struct symbol_in_block rather than a mere symbol. * linespec.c (find_label_symbols): Deal with struct symbol_in_block from lookup functions. * m2-exp.y: Likewise. Remove uses of block_found. (yylex): Likewise. * mi/mi-cmd-stack.c (list_args_or_locals): Likewise. * objc-lang.c (lookup_struct_typedef, find_imps): Likewise. * p-exp.y: Likewise. Remove uses of block_found. (yylex): Likewise. * p-valprint.c (pascal_val_print): Likewise. * parse.c (write_dollar_variable): Likewise. Remove uses of block_found. * parser-defs.h (struct symtoken): Turn the SYM field into a struct symbol_in_block. * printcmd.c (address_info): Deal with struct symbol_in_block from lookup functions. * python/py-frame.c (frapy_read_var): Likewise. * python/py-symbol.c (gdbpy_lookup_symbol, gdbpy_lookup_global_symbol): Likewise. * skip.c (skip_function_command): Likewise. * solib-darwin.c (darwin_lookup_lib_symbol): Return a struct symbol_in_block instead of a mere symbol. * solib-spu.c (spu_lookup_lib_symbol): Likewise. * solib-svr4.c (elf_lookup_lib_symbol): Likewise. * solib.c (solib_global_lookup): Likewise. * solist.h (solib_global_lookup): Likewise. (struct target_so_ops): Update lookup_lib_global_symbol to return a struct symbol_in_block rather than a mere symbol. * source.c (select_source_symtab): Deal with struct symbol_in_block from lookup functions. * stack.c (print_frame_args, iterate_over_block_arg_vars): Likewise. * symfile.c (set_initial_language): Likewise. * symtab.c (SYMBOL_LOOKUP_FAILED): Turn into a struct symbol_in_block. (SYMBOL_LOOKUP_FAILED_P): New predicate as a macro. (struct symbol_cache_slot): Turn the FOUND field into a struct symbol_in_block. (block_found): Remove. (eq_symbol_entry): Update to deal with struct symbol_in_block in cache slots. (symbol_cache_lookup): Return a struct symbol_in_block rather than a mere symbol. (symbol_cache_mark_found): Add a BLOCK parameter to fill appropriately the cache slots. Update callers. (symbol_cache_dump): Update cache slots handling to the type change. (lookup_symbol_in_language, lookup_symbol, lookup_language_this, lookup_symbol_aux, lookup_local_symbol, lookup_symbol_in_objfile, lookup_global_symbol_from_objfile, lookup_symbol_in_objfile_symtabs, lookup_symbol_in_objfile_from_linkage_name, lookup_symbol_via_quick_fns, basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block, lookup_static_symbol, lookup_global_symbol): Return a struct symbol_in_block rather than a mere symbol. Deal with struct symbol_in_block from other lookup functions. Remove uses of block_found. (lookup_symbol_in_block): Remove uses of block_found. (struct global_sym_lookup_data): Turn the RESULT field into a struct symbol_in_block. (lookup_symbol_global_iterator_cb): Update references to the RESULT field. (search_symbols): Deal with struct symbol_in_block from lookup functions. * symtab.h (struct symbol_in_block): New structure. (block_found): Remove. (lookup_symbol_in_language, lookup_symbol, basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block, looku_static_symbol, lookup_global_symbol, lookup_symbol_in_block, lookup_language_this, lookup_global_symbol_from_objfile): Return a struct symbol_in_block rather than just a mere symbol. Update comments to remove mentions of block_found. * valops.c (find_function_in_inferior, value_struct_elt_for_reference, value_maybe_namespace_elt, value_of_this): Deal with struct symbol_in_block from lookup functions. * value.c (value_static_field, value_fn_field): Likewise.
2015-07-21 17:02:15 +02:00
if (ada_prefer_type (SYMBOL_TYPE (syms[i].symbol), preferred_type))
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
{
preferred_index = i;
Replace the block_found global with explicit data-flow As Pedro suggested on gdb-patches@ (see https://sourceware.org/ml/gdb-patches/2015-05/msg00714.html), this change makes symbol lookup functions return a structure that includes both the symbol found and the block in which it was found. This makes it possible to get rid of the block_found global variable and thus makes block hunting explicit. gdb/ * ada-exp.y (write_object_renaming): Replace struct ada_symbol_info with struct block_symbol. Update field references accordingly. (block_lookup, select_possible_type_sym): Likewise. (find_primitive_type): Likewise. Also update call to ada_lookup_symbol to extract the symbol itself. (write_var_or_type, write_name_assoc): Likewise. * ada-lang.h (struct ada_symbol_info): Remove. (ada_lookup_symbol_list): Replace struct ada_symbol_info with struct block_symbol. (ada_lookup_encoded_symbol, user_select_syms): Likewise. (ada_lookup_symbol): Return struct block_symbol instead of a mere symbol. * ada-lang.c (defns_collected): Replace struct ada_symbol_info with struct block_symbol. (resolve_subexp, ada_resolve_function, sort_choices, user_select_syms, is_nonfunction, add_defn_to_vec, num_defns_collected, defns_collected, symbols_are_identical_enums, remove_extra_symbols, remove_irrelevant_renamings, add_lookup_symbol_list_worker, ada_lookup_symbol_list, ada_iterate_over_symbols, ada_lookup_encoded_symbol, get_var_value): Likewise. (ada_lookup_symbol): Return a block_symbol instead of a mere symbol. Replace struct ada_symbol_info with struct block_symbol. (ada_lookup_symbol_nonlocal): Likewise. (standard_lookup): Make block passing explicit through lookup_symbol_in_language. * ada-tasks.c (get_tcb_types_info): Update the calls to lookup_symbol_in_language to extract the mere symbol out of the returned value. (ada_tasks_inferior_data_sniffer): Likewise. * ax-gdb.c (gen_static_field): Likewise for the call to lookup_symbol. (gen_maybe_namespace_elt): Deal with struct symbol_in_block from lookup functions. (gen_expr): Likewise. * c-exp.y: Likewise. Remove uses of block_found. (lex_one_token, classify_inner_name, c_print_token): Likewise. (classify_name): Likewise. Rename the "sym" local variable to "bsym". * c-valprint.c (print_unpacked_pointer): Likewise. * compile/compile-c-symbols.c (convert_symbol_sym): Promote the "sym" parameter from struct symbol * to struct block_symbol. Use it to remove uses of block_found. Deal with struct symbol_in_block from lookup functions. (gcc_convert_symbol): Likewise. Update the call to convert_symbol_sym. * compile/compile-object-load.c (compile_object_load): Deal with struct symbol_in_block from lookup functions. * cp-namespace.c (cp_lookup_nested_symbol_1, cp_lookup_nested_symbol, cp_lookup_bare_symbol, cp_search_static_and_baseclasses, cp_lookup_symbol_in_namespace, cp_lookup_symbol_via_imports, cp_lookup_symbol_imports_or_template, cp_lookup_symbol_via_all_imports, cp_lookup_symbol_namespace, lookup_namespace_scope, cp_lookup_nonlocal, find_symbol_in_baseclass): Return struct symbol_in_block instead of mere symbols and deal with struct symbol_in_block from lookup functions. * cp-support.c (inspect_type, replace_typedefs, cp_lookup_rtti_type): Deal with struct symbol_in_block from lookup functions. * cp-support.h (cp_lookup_symbol_nonlocal, cp_lookup_symbol_from_namespace, cp_lookup_symbol_imports_or_template, cp_lookup_nested_symbol): Return struct symbol_in_block instead of mere symbols. * d-exp.y (d_type_from_name, d_module_from_name, push_variable, push_module_name): Deal with struct symbol_in_block from lookup functions. Remove uses of block_found. * eval.c (evaluate_subexp_standard): Update call to cp_lookup_symbol_namespace. * f-exp.y: Deal with struct symbol_in_block from lookup functions. Remove uses of block_found. (yylex): Likewise. * gdbtypes.c (lookup_typename, lookup_struct, lookup_union, lookup_enum, lookup_template_type, check_typedef): Deal with struct symbol_in_block from lookup functions. * guile/scm-frame.c (gdbscm_frame_read_var): Likewise. * guile/scm-symbol.c (gdbscm_lookup_symbol): Likewise. (gdbscm_lookup_global_symbol): Likewise. * gnu-v3-abi.c (gnuv3_get_typeid_type): Likewise. * go-exp.y: Likewise. Remove uses of block_found. (package_name_p, classify_packaged_name, classify_name): Likewise. * infrun.c (insert_exception_resume_breakpoint): Likewise. * jv-exp.y (push_variable): Likewise. * jv-lang.c (java_lookup_class, get_java_object_type): Likewise. * language.c (language_bool_type): Likewise. * language.h (struct language_defn): Update la_lookup_symbol_nonlocal to return a struct symbol_in_block rather than a mere symbol. * linespec.c (find_label_symbols): Deal with struct symbol_in_block from lookup functions. * m2-exp.y: Likewise. Remove uses of block_found. (yylex): Likewise. * mi/mi-cmd-stack.c (list_args_or_locals): Likewise. * objc-lang.c (lookup_struct_typedef, find_imps): Likewise. * p-exp.y: Likewise. Remove uses of block_found. (yylex): Likewise. * p-valprint.c (pascal_val_print): Likewise. * parse.c (write_dollar_variable): Likewise. Remove uses of block_found. * parser-defs.h (struct symtoken): Turn the SYM field into a struct symbol_in_block. * printcmd.c (address_info): Deal with struct symbol_in_block from lookup functions. * python/py-frame.c (frapy_read_var): Likewise. * python/py-symbol.c (gdbpy_lookup_symbol, gdbpy_lookup_global_symbol): Likewise. * skip.c (skip_function_command): Likewise. * solib-darwin.c (darwin_lookup_lib_symbol): Return a struct symbol_in_block instead of a mere symbol. * solib-spu.c (spu_lookup_lib_symbol): Likewise. * solib-svr4.c (elf_lookup_lib_symbol): Likewise. * solib.c (solib_global_lookup): Likewise. * solist.h (solib_global_lookup): Likewise. (struct target_so_ops): Update lookup_lib_global_symbol to return a struct symbol_in_block rather than a mere symbol. * source.c (select_source_symtab): Deal with struct symbol_in_block from lookup functions. * stack.c (print_frame_args, iterate_over_block_arg_vars): Likewise. * symfile.c (set_initial_language): Likewise. * symtab.c (SYMBOL_LOOKUP_FAILED): Turn into a struct symbol_in_block. (SYMBOL_LOOKUP_FAILED_P): New predicate as a macro. (struct symbol_cache_slot): Turn the FOUND field into a struct symbol_in_block. (block_found): Remove. (eq_symbol_entry): Update to deal with struct symbol_in_block in cache slots. (symbol_cache_lookup): Return a struct symbol_in_block rather than a mere symbol. (symbol_cache_mark_found): Add a BLOCK parameter to fill appropriately the cache slots. Update callers. (symbol_cache_dump): Update cache slots handling to the type change. (lookup_symbol_in_language, lookup_symbol, lookup_language_this, lookup_symbol_aux, lookup_local_symbol, lookup_symbol_in_objfile, lookup_global_symbol_from_objfile, lookup_symbol_in_objfile_symtabs, lookup_symbol_in_objfile_from_linkage_name, lookup_symbol_via_quick_fns, basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block, lookup_static_symbol, lookup_global_symbol): Return a struct symbol_in_block rather than a mere symbol. Deal with struct symbol_in_block from other lookup functions. Remove uses of block_found. (lookup_symbol_in_block): Remove uses of block_found. (struct global_sym_lookup_data): Turn the RESULT field into a struct symbol_in_block. (lookup_symbol_global_iterator_cb): Update references to the RESULT field. (search_symbols): Deal with struct symbol_in_block from lookup functions. * symtab.h (struct symbol_in_block): New structure. (block_found): Remove. (lookup_symbol_in_language, lookup_symbol, basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block, looku_static_symbol, lookup_global_symbol, lookup_symbol_in_block, lookup_language_this, lookup_global_symbol_from_objfile): Return a struct symbol_in_block rather than just a mere symbol. Update comments to remove mentions of block_found. * valops.c (find_function_in_inferior, value_struct_elt_for_reference, value_maybe_namespace_elt, value_of_this): Deal with struct symbol_in_block from lookup functions. * value.c (value_static_field, value_fn_field): Likewise.
2015-07-21 17:02:15 +02:00
preferred_type = SYMBOL_TYPE (syms[i].symbol);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
}
break;
case LOC_REGISTER:
case LOC_ARG:
case LOC_REF_ARG:
case LOC_REGPARM_ADDR:
case LOC_LOCAL:
case LOC_COMPUTED:
return NULL;
default:
break;
}
if (preferred_type == NULL)
return NULL;
Replace the block_found global with explicit data-flow As Pedro suggested on gdb-patches@ (see https://sourceware.org/ml/gdb-patches/2015-05/msg00714.html), this change makes symbol lookup functions return a structure that includes both the symbol found and the block in which it was found. This makes it possible to get rid of the block_found global variable and thus makes block hunting explicit. gdb/ * ada-exp.y (write_object_renaming): Replace struct ada_symbol_info with struct block_symbol. Update field references accordingly. (block_lookup, select_possible_type_sym): Likewise. (find_primitive_type): Likewise. Also update call to ada_lookup_symbol to extract the symbol itself. (write_var_or_type, write_name_assoc): Likewise. * ada-lang.h (struct ada_symbol_info): Remove. (ada_lookup_symbol_list): Replace struct ada_symbol_info with struct block_symbol. (ada_lookup_encoded_symbol, user_select_syms): Likewise. (ada_lookup_symbol): Return struct block_symbol instead of a mere symbol. * ada-lang.c (defns_collected): Replace struct ada_symbol_info with struct block_symbol. (resolve_subexp, ada_resolve_function, sort_choices, user_select_syms, is_nonfunction, add_defn_to_vec, num_defns_collected, defns_collected, symbols_are_identical_enums, remove_extra_symbols, remove_irrelevant_renamings, add_lookup_symbol_list_worker, ada_lookup_symbol_list, ada_iterate_over_symbols, ada_lookup_encoded_symbol, get_var_value): Likewise. (ada_lookup_symbol): Return a block_symbol instead of a mere symbol. Replace struct ada_symbol_info with struct block_symbol. (ada_lookup_symbol_nonlocal): Likewise. (standard_lookup): Make block passing explicit through lookup_symbol_in_language. * ada-tasks.c (get_tcb_types_info): Update the calls to lookup_symbol_in_language to extract the mere symbol out of the returned value. (ada_tasks_inferior_data_sniffer): Likewise. * ax-gdb.c (gen_static_field): Likewise for the call to lookup_symbol. (gen_maybe_namespace_elt): Deal with struct symbol_in_block from lookup functions. (gen_expr): Likewise. * c-exp.y: Likewise. Remove uses of block_found. (lex_one_token, classify_inner_name, c_print_token): Likewise. (classify_name): Likewise. Rename the "sym" local variable to "bsym". * c-valprint.c (print_unpacked_pointer): Likewise. * compile/compile-c-symbols.c (convert_symbol_sym): Promote the "sym" parameter from struct symbol * to struct block_symbol. Use it to remove uses of block_found. Deal with struct symbol_in_block from lookup functions. (gcc_convert_symbol): Likewise. Update the call to convert_symbol_sym. * compile/compile-object-load.c (compile_object_load): Deal with struct symbol_in_block from lookup functions. * cp-namespace.c (cp_lookup_nested_symbol_1, cp_lookup_nested_symbol, cp_lookup_bare_symbol, cp_search_static_and_baseclasses, cp_lookup_symbol_in_namespace, cp_lookup_symbol_via_imports, cp_lookup_symbol_imports_or_template, cp_lookup_symbol_via_all_imports, cp_lookup_symbol_namespace, lookup_namespace_scope, cp_lookup_nonlocal, find_symbol_in_baseclass): Return struct symbol_in_block instead of mere symbols and deal with struct symbol_in_block from lookup functions. * cp-support.c (inspect_type, replace_typedefs, cp_lookup_rtti_type): Deal with struct symbol_in_block from lookup functions. * cp-support.h (cp_lookup_symbol_nonlocal, cp_lookup_symbol_from_namespace, cp_lookup_symbol_imports_or_template, cp_lookup_nested_symbol): Return struct symbol_in_block instead of mere symbols. * d-exp.y (d_type_from_name, d_module_from_name, push_variable, push_module_name): Deal with struct symbol_in_block from lookup functions. Remove uses of block_found. * eval.c (evaluate_subexp_standard): Update call to cp_lookup_symbol_namespace. * f-exp.y: Deal with struct symbol_in_block from lookup functions. Remove uses of block_found. (yylex): Likewise. * gdbtypes.c (lookup_typename, lookup_struct, lookup_union, lookup_enum, lookup_template_type, check_typedef): Deal with struct symbol_in_block from lookup functions. * guile/scm-frame.c (gdbscm_frame_read_var): Likewise. * guile/scm-symbol.c (gdbscm_lookup_symbol): Likewise. (gdbscm_lookup_global_symbol): Likewise. * gnu-v3-abi.c (gnuv3_get_typeid_type): Likewise. * go-exp.y: Likewise. Remove uses of block_found. (package_name_p, classify_packaged_name, classify_name): Likewise. * infrun.c (insert_exception_resume_breakpoint): Likewise. * jv-exp.y (push_variable): Likewise. * jv-lang.c (java_lookup_class, get_java_object_type): Likewise. * language.c (language_bool_type): Likewise. * language.h (struct language_defn): Update la_lookup_symbol_nonlocal to return a struct symbol_in_block rather than a mere symbol. * linespec.c (find_label_symbols): Deal with struct symbol_in_block from lookup functions. * m2-exp.y: Likewise. Remove uses of block_found. (yylex): Likewise. * mi/mi-cmd-stack.c (list_args_or_locals): Likewise. * objc-lang.c (lookup_struct_typedef, find_imps): Likewise. * p-exp.y: Likewise. Remove uses of block_found. (yylex): Likewise. * p-valprint.c (pascal_val_print): Likewise. * parse.c (write_dollar_variable): Likewise. Remove uses of block_found. * parser-defs.h (struct symtoken): Turn the SYM field into a struct symbol_in_block. * printcmd.c (address_info): Deal with struct symbol_in_block from lookup functions. * python/py-frame.c (frapy_read_var): Likewise. * python/py-symbol.c (gdbpy_lookup_symbol, gdbpy_lookup_global_symbol): Likewise. * skip.c (skip_function_command): Likewise. * solib-darwin.c (darwin_lookup_lib_symbol): Return a struct symbol_in_block instead of a mere symbol. * solib-spu.c (spu_lookup_lib_symbol): Likewise. * solib-svr4.c (elf_lookup_lib_symbol): Likewise. * solib.c (solib_global_lookup): Likewise. * solist.h (solib_global_lookup): Likewise. (struct target_so_ops): Update lookup_lib_global_symbol to return a struct symbol_in_block rather than a mere symbol. * source.c (select_source_symtab): Deal with struct symbol_in_block from lookup functions. * stack.c (print_frame_args, iterate_over_block_arg_vars): Likewise. * symfile.c (set_initial_language): Likewise. * symtab.c (SYMBOL_LOOKUP_FAILED): Turn into a struct symbol_in_block. (SYMBOL_LOOKUP_FAILED_P): New predicate as a macro. (struct symbol_cache_slot): Turn the FOUND field into a struct symbol_in_block. (block_found): Remove. (eq_symbol_entry): Update to deal with struct symbol_in_block in cache slots. (symbol_cache_lookup): Return a struct symbol_in_block rather than a mere symbol. (symbol_cache_mark_found): Add a BLOCK parameter to fill appropriately the cache slots. Update callers. (symbol_cache_dump): Update cache slots handling to the type change. (lookup_symbol_in_language, lookup_symbol, lookup_language_this, lookup_symbol_aux, lookup_local_symbol, lookup_symbol_in_objfile, lookup_global_symbol_from_objfile, lookup_symbol_in_objfile_symtabs, lookup_symbol_in_objfile_from_linkage_name, lookup_symbol_via_quick_fns, basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block, lookup_static_symbol, lookup_global_symbol): Return a struct symbol_in_block rather than a mere symbol. Deal with struct symbol_in_block from other lookup functions. Remove uses of block_found. (lookup_symbol_in_block): Remove uses of block_found. (struct global_sym_lookup_data): Turn the RESULT field into a struct symbol_in_block. (lookup_symbol_global_iterator_cb): Update references to the RESULT field. (search_symbols): Deal with struct symbol_in_block from lookup functions. * symtab.h (struct symbol_in_block): New structure. (block_found): Remove. (lookup_symbol_in_language, lookup_symbol, basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block, looku_static_symbol, lookup_global_symbol, lookup_symbol_in_block, lookup_language_this, lookup_global_symbol_from_objfile): Return a struct symbol_in_block rather than just a mere symbol. Update comments to remove mentions of block_found. * valops.c (find_function_in_inferior, value_struct_elt_for_reference, value_maybe_namespace_elt, value_of_this): Deal with struct symbol_in_block from lookup functions. * value.c (value_static_field, value_fn_field): Likewise.
2015-07-21 17:02:15 +02:00
return syms[preferred_index].symbol;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
}
static struct type*
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
find_primitive_type (struct parser_state *par_state, char *name)
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
{
struct type *type;
type = language_lookup_primitive_type (par_state->language (),
par_state->gdbarch (),
name);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
if (type == NULL && strcmp ("system__address", name) == 0)
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
type = type_system_address (par_state);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
if (type != NULL)
{
/* Check to see if we have a regular definition of this
type that just didn't happen to have been read yet. */
struct symbol *sym;
char *expanded_name =
(char *) alloca (strlen (name) + sizeof ("standard__"));
strcpy (expanded_name, "standard__");
strcat (expanded_name, name);
sym = ada_lookup_symbol (expanded_name, NULL, VAR_DOMAIN).symbol;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
if (sym != NULL && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
type = SYMBOL_TYPE (sym);
}
return type;
}
static int
chop_selector (char *name, int end)
{
int i;
for (i = end - 1; i > 0; i -= 1)
if (name[i] == '.' || (name[i] == '_' && name[i+1] == '_'))
return i;
return -1;
}
/* If NAME is a string beginning with a separator (either '__', or
'.'), chop this separator and return the result; else, return
NAME. */
static char *
chop_separator (char *name)
{
if (*name == '.')
return name + 1;
if (name[0] == '_' && name[1] == '_')
return name + 2;
return name;
}
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
/* Given that SELS is a string of the form (<sep><identifier>)*, where
<sep> is '__' or '.', write the indicated sequence of
STRUCTOP_STRUCT expression operators. */
static void
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_selectors (struct parser_state *par_state, char *sels)
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
{
while (*sels != '\0')
{
struct stoken field_name;
char *p = chop_separator (sels);
sels = p;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
while (*sels != '\0' && *sels != '.'
&& (sels[0] != '_' || sels[1] != '_'))
sels += 1;
field_name.length = sels - p;
field_name.ptr = p;
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_exp_op_with_string (par_state, STRUCTOP_STRUCT, field_name);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
}
}
/* Write a variable access (OP_VAR_VALUE) to ambiguous encoded name
NAME[0..LEN-1], in block context BLOCK, to be resolved later. Writes
a temporary symbol that is valid until the next call to ada_parse.
*/
static void
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_ambiguous_var (struct parser_state *par_state,
const struct block *block, char *name, int len)
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
{
Make struct symbol inherit from general_symbol_info Since this is now no longer a POD, also give it a constructor that initializes all fields. (I have considered overloading operator new to zero-initialize the memory instead; let me know if you prefer that) gdb/ChangeLog: 2019-11-12 Christian Biesinger <cbiesinger@google.com> * ada-exp.y (write_ambiguous_var): Update. * buildsym.c (add_symbol_to_list): Update. * dwarf2read.c (read_variable): Update. (new_symbol): Update. * jit.c (finalize_symtab): Update. * language.c (language_alloc_type_symbol): Update. * symtab.c (fixup_symbol_section): Update. (initialize_objfile_symbol_1): Move code to... (initialize_objfile_symbol): ...here. Remove now-unnecessary memset. (allocate_symbol): Update. (allocate_template_symbol): Update. (get_symbol_address): Update. * symtab.h (struct symbol): Inherit from general_symbol_info instead of having as a field, and add a constructor. (SYMBOL_VALUE): Update. (SYMBOL_VALUE_ADDRESS): Update. (SET_SYMBOL_VALUE_ADDRESS): Update. (SYMBOL_VALUE_BYTES): Update. (SYMBOL_VALUE_COMMON_BLOCK): Update. (SYMBOL_BLOCK_VALUE): Update. (SYMBOL_VALUE_CHAIN): Update. (SYMBOL_LANGUAGE): Update. (SYMBOL_SECTION): Update. (SYMBOL_OBJ_SECTION): Update. (SYMBOL_SET_LANGUAGE): Update. (SYMBOL_SET_LINKAGE_NAME): Update. (SYMBOL_SET_NAMES): Update. (SYMBOL_NATURAL_NAME): Update. (SYMBOL_LINKAGE_NAME): Update. (SYMBOL_DEMANGLED_NAME): Update. (SYMBOL_SEARCH_NAME): Update. (SYMBOL_MATCHES_SEARCH_NAME): Update. (struct symbol): Update. (struct template_symbol): Update. (struct rust_vtable_symbol): Update. * xcoffread.c (SYMBOL_DUP): Update. Change-Id: I05b1628455bcce3efaa101e65ef051708d17eb07
2019-11-04 20:12:09 +01:00
struct symbol *sym = new (&temp_parse_space) symbol ();
Replace some xmalloc-family functions with XNEW-family ones This patch is part of the make-gdb-buildable-in-C++ effort. The idea is to change some calls to the xmalloc family of functions to calls to the equivalents in the XNEW family. This avoids adding an explicit cast, so it keeps the code a bit more readable. Some of them also map relatively well to a C++ equivalent (XNEW (struct foo) -> new foo), so it will be possible to do scripted replacements if needed. I only changed calls that were obviously allocating memory for one or multiple "objects". Allocation of variable sizes (such as strings or buffer handling) will be for later (and won't use XNEW). - xmalloc (sizeof (struct foo)) -> XNEW (struct foo) - xmalloc (num * sizeof (struct foo)) -> XNEWVEC (struct foo, num) - xcalloc (1, sizeof (struct foo)) -> XCNEW (struct foo) - xcalloc (num, sizeof (struct foo)) -> XCNEWVEC (struct foo, num) - xrealloc (p, num * sizeof (struct foo) -> XRESIZEVEC (struct foo, p, num) - obstack_alloc (ob, sizeof (struct foo)) -> XOBNEW (ob, struct foo) - obstack_alloc (ob, num * sizeof (struct foo)) -> XOBNEWVEC (ob, struct foo, num) - alloca (sizeof (struct foo)) -> XALLOCA (struct foo) - alloca (num * sizeof (struct foo)) -> XALLOCAVEC (struct foo, num) Some instances of xmalloc followed by memset to zero the buffer were replaced by XCNEW or XCNEWVEC. I regtested on x86-64, Ubuntu 14.04, but the patch touches many architecture-specific files. For those I'll have to rely on the buildbot or people complaining that I broke their gdb. gdb/ChangeLog: * aarch64-linux-nat.c (aarch64_add_process): Likewise. * aarch64-tdep.c (aarch64_gdbarch_init): Likewise. * ada-exp.y (write_ambiguous_var): Likewise. * ada-lang.c (resolve_subexp): Likewise. (user_select_syms): Likewise. (assign_aggregate): Likewise. (ada_evaluate_subexp): Likewise. (cache_symbol): Likewise. * addrmap.c (allocate_key): Likewise. (addrmap_create_mutable): Likewise. * aix-thread.c (sync_threadlists): Likewise. * alpha-tdep.c (alpha_push_dummy_call): Likewise. (alpha_gdbarch_init): Likewise. * amd64-windows-tdep.c (amd64_windows_push_arguments): Likewise. * arm-linux-nat.c (arm_linux_add_process): Likewise. * arm-linux-tdep.c (arm_linux_displaced_step_copy_insn): Likewise. * arm-tdep.c (push_stack_item): Likewise. (arm_displaced_step_copy_insn): Likewise. (arm_gdbarch_init): Likewise. (_initialize_arm_tdep): Likewise. * avr-tdep.c (push_stack_item): Likewise. * ax-general.c (new_agent_expr): Likewise. * block.c (block_initialize_namespace): Likewise. * breakpoint.c (alloc_counted_command_line): Likewise. (update_dprintf_command_list): Likewise. (parse_breakpoint_sals): Likewise. (decode_static_tracepoint_spec): Likewise. (until_break_command): Likewise. (clear_command): Likewise. (update_global_location_list): Likewise. (get_breakpoint_objfile_data) Likewise. * btrace.c (ftrace_new_function): Likewise. (btrace_set_insn_history): Likewise. (btrace_set_call_history): Likewise. * buildsym.c (add_symbol_to_list): Likewise. (record_pending_block): Likewise. (start_subfile): Likewise. (start_buildsym_compunit): Likewise. (push_subfile): Likewise. (end_symtab_get_static_block): Likewise. (buildsym_init): Likewise. * cli/cli-cmds.c (source_command): Likewise. * cli/cli-decode.c (add_cmd): Likewise. * cli/cli-script.c (build_command_line): Likewise. (setup_user_args): Likewise. (realloc_body_list): Likewise. (process_next_line): Likewise. (copy_command_lines): Likewise. * cli/cli-setshow.c (do_set_command): Likewise. * coff-pe-read.c (read_pe_exported_syms): Likewise. * coffread.c (coff_locate_sections): Likewise. (coff_symtab_read): Likewise. (coff_read_struct_type): Likewise. * common/cleanups.c (make_my_cleanup2): Likewise. * common/common-exceptions.c (throw_it): Likewise. * common/filestuff.c (make_cleanup_close): Likewise. * common/format.c (parse_format_string): Likewise. * common/queue.h (DEFINE_QUEUE_P): Likewise. * compile/compile-object-load.c (munmap_list_add): Likewise. (compile_object_load): Likewise. * compile/compile-object-run.c (compile_object_run): Likewise. * compile/compile.c (append_args): Likewise. * corefile.c (specify_exec_file_hook): Likewise. * cp-support.c (make_symbol_overload_list): Likewise. * cris-tdep.c (push_stack_item): Likewise. (cris_gdbarch_init): Likewise. * ctf.c (ctf_trace_file_writer_new): Likewise. * dbxread.c (init_header_files): Likewise. (add_new_header_file): Likewise. (init_bincl_list): Likewise. (dbx_end_psymtab): Likewise. (start_psymtab): Likewise. (dbx_end_psymtab): Likewise. * dcache.c (dcache_init): Likewise. * dictionary.c (dict_create_hashed): Likewise. (dict_create_hashed_expandable): Likewise. (dict_create_linear): Likewise. (dict_create_linear_expandable): Likewise. * dtrace-probe.c (dtrace_process_dof_probe): Likewise. * dummy-frame.c (register_dummy_frame_dtor): Likewise. * dwarf2-frame-tailcall.c (cache_new_ref1): Likewise. * dwarf2-frame.c (dwarf2_build_frame_info): Likewise. (decode_frame_entry_1): Likewise. * dwarf2expr.c (new_dwarf_expr_context): Likewise. * dwarf2loc.c (dwarf2_compile_expr_to_ax): Likewise. * dwarf2read.c (dwarf2_has_info): Likewise. (create_signatured_type_table_from_index): Likewise. (dwarf2_read_index): Likewise. (dw2_get_file_names_reader): Likewise. (create_all_type_units): Likewise. (read_cutu_die_from_dwo): Likewise. (init_tu_and_read_dwo_dies): Likewise. (init_cutu_and_read_dies): Likewise. (create_all_comp_units): Likewise. (queue_comp_unit): Likewise. (inherit_abstract_dies): Likewise. (read_call_site_scope): Likewise. (dwarf2_add_field): Likewise. (dwarf2_add_typedef): Likewise. (dwarf2_add_member_fn): Likewise. (attr_to_dynamic_prop): Likewise. (abbrev_table_alloc_abbrev): Likewise. (abbrev_table_read_table): Likewise. (add_include_dir): Likewise. (add_file_name): Likewise. (dwarf_decode_line_header): Likewise. (dwarf2_const_value_attr): Likewise. (dwarf_alloc_block): Likewise. (parse_macro_definition): Likewise. (set_die_type): Likewise. (write_psymtabs_to_index): Likewise. (create_cus_from_index): Likewise. (dwarf2_create_include_psymtab): Likewise. (process_psymtab_comp_unit_reader): Likewise. (build_type_psymtab_dependencies): Likewise. (read_comp_units_from_section): Likewise. (compute_compunit_symtab_includes): Likewise. (create_dwo_unit_in_dwp_v1): Likewise. (create_dwo_unit_in_dwp_v2): Likewise. (read_func_scope): Likewise. (process_structure_scope): Likewise. (mark_common_block_symbol_computed): Likewise. (load_partial_dies): Likewise. (dwarf2_symbol_mark_computed): Likewise. * elfread.c (elf_symfile_segments): Likewise. (elf_read_minimal_symbols): Likewise. * environ.c (make_environ): Likewise. * eval.c (evaluate_subexp_standard): Likewise. * event-loop.c (create_file_handler): Likewise. (create_async_signal_handler): Likewise. (create_async_event_handler): Likewise. (create_timer): Likewise. * exec.c (build_section_table): Likewise. * fbsd-nat.c (fbsd_remember_child): Likewise. * fork-child.c (fork_inferior): Likewise. * frv-tdep.c (new_variant): Likewise. * gdbarch.sh (gdbarch_alloc): Likewise. (append_name): Likewise. * gdbtypes.c (rank_function): Likewise. (copy_type_recursive): Likewise. (add_dyn_prop): Likewise. * gnu-nat.c (make_proc): Likewise. (make_inf): Likewise. (gnu_write_inferior): Likewise. * gnu-v3-abi.c (build_gdb_vtable_type): Likewise. (build_std_type_info_type): Likewise. * guile/scm-param.c (compute_enum_list): Likewise. * guile/scm-utils.c (gdbscm_parse_function_args): Likewise. * guile/scm-value.c (gdbscm_value_call): Likewise. * h8300-tdep.c (h8300_gdbarch_init): Likewise. * hppa-tdep.c (hppa_init_objfile_priv_data): Likewise. (read_unwind_info): Likewise. * ia64-tdep.c (ia64_gdbarch_init): Likewise. * infcall.c (dummy_frame_context_saver_setup): Likewise. (call_function_by_hand_dummy): Likewise. * infcmd.c (step_once): Likewise. (finish_forward): Likewise. (attach_command): Likewise. (notice_new_inferior): Likewise. * inferior.c (add_inferior_silent): Likewise. * infrun.c (add_displaced_stepping_state): Likewise. (save_infcall_control_state): Likewise. (save_inferior_ptid): Likewise. (_initialize_infrun): Likewise. * jit.c (bfd_open_from_target_memory): Likewise. (jit_gdbarch_data_init): Likewise. * language.c (add_language): Likewise. * linespec.c (decode_line_2): Likewise. * linux-nat.c (add_to_pid_list): Likewise. (add_initial_lwp): Likewise. * linux-thread-db.c (add_thread_db_info): Likewise. (record_thread): Likewise. (info_auto_load_libthread_db): Likewise. * m32c-tdep.c (m32c_gdbarch_init): Likewise. * m68hc11-tdep.c (m68hc11_gdbarch_init): Likewise. * m68k-tdep.c (m68k_gdbarch_init): Likewise. * m88k-tdep.c (m88k_analyze_prologue): Likewise. * macrocmd.c (macro_define_command): Likewise. * macroexp.c (gather_arguments): Likewise. * macroscope.c (sal_macro_scope): Likewise. * macrotab.c (new_macro_table): Likewise. * mdebugread.c (push_parse_stack): Likewise. (parse_partial_symbols): Likewise. (parse_symbol): Likewise. (psymtab_to_symtab_1): Likewise. (new_block): Likewise. (new_psymtab): Likewise. (mdebug_build_psymtabs): Likewise. (add_pending): Likewise. (elfmdebug_build_psymtabs): Likewise. * mep-tdep.c (mep_gdbarch_init): Likewise. * mi/mi-main.c (mi_execute_command): Likewise. * mi/mi-parse.c (mi_parse_argv): Likewise. * minidebug.c (lzma_open): Likewise. * minsyms.c (terminate_minimal_symbol_table): Likewise. * mips-linux-nat.c (mips_linux_insert_watchpoint): Likewise. * mips-tdep.c (mips_gdbarch_init): Likewise. * mn10300-tdep.c (mn10300_gdbarch_init): Likewise. * msp430-tdep.c (msp430_gdbarch_init): Likewise. * mt-tdep.c (mt_registers_info): Likewise. * nat/aarch64-linux.c (aarch64_linux_new_thread): Likewise. * nat/linux-btrace.c (linux_enable_bts): Likewise. (linux_enable_pt): Likewise. * nat/linux-osdata.c (linux_xfer_osdata_processes): Likewise. (linux_xfer_osdata_processgroups): Likewise. * nios2-tdep.c (nios2_gdbarch_init): Likewise. * nto-procfs.c (procfs_meminfo): Likewise. * objc-lang.c (start_msglist): Likewise. (selectors_info): Likewise. (classes_info): Likewise. (find_methods): Likewise. * objfiles.c (allocate_objfile): Likewise. (update_section_map): Likewise. * osabi.c (gdbarch_register_osabi): Likewise. (gdbarch_register_osabi_sniffer): Likewise. * parse.c (start_arglist): Likewise. * ppc-linux-nat.c (hwdebug_find_thread_points_by_tid): Likewise. (hwdebug_insert_point): Likewise. * printcmd.c (display_command): Likewise. (ui_printf): Likewise. * procfs.c (create_procinfo): Likewise. (load_syscalls): Likewise. (proc_get_LDT_entry): Likewise. (proc_update_threads): Likewise. * prologue-value.c (make_pv_area): Likewise. (pv_area_store): Likewise. * psymtab.c (extend_psymbol_list): Likewise. (init_psymbol_list): Likewise. (allocate_psymtab): Likewise. * python/py-inferior.c (add_thread_object): Likewise. * python/py-param.c (compute_enum_values): Likewise. * python/py-value.c (valpy_call): Likewise. * python/py-varobj.c (py_varobj_iter_next): Likewise. * python/python.c (ensure_python_env): Likewise. * record-btrace.c (record_btrace_start_replaying): Likewise. * record-full.c (record_full_reg_alloc): Likewise. (record_full_mem_alloc): Likewise. (record_full_end_alloc): Likewise. (record_full_core_xfer_partial): Likewise. * regcache.c (get_thread_arch_aspace_regcache): Likewise. * remote-fileio.c (remote_fileio_init_fd_map): Likewise. * remote-notif.c (remote_notif_state_allocate): Likewise. * remote.c (demand_private_info): Likewise. (remote_notif_stop_alloc_reply): Likewise. (remote_enable_btrace): Likewise. * reverse.c (save_bookmark_command): Likewise. * rl78-tdep.c (rl78_gdbarch_init): Likewise. * rx-tdep.c (rx_gdbarch_init): Likewise. * s390-linux-nat.c (s390_insert_watchpoint): Likewise. * ser-go32.c (dos_get_tty_state): Likewise. (dos_copy_tty_state): Likewise. * ser-mingw.c (ser_windows_open): Likewise. (ser_console_wait_handle): Likewise. (ser_console_get_tty_state): Likewise. (make_pipe_state): Likewise. (net_windows_open): Likewise. * ser-unix.c (hardwire_get_tty_state): Likewise. (hardwire_copy_tty_state): Likewise. * solib-aix.c (solib_aix_new_lm_info): Likewise. * solib-dsbt.c (dsbt_current_sos): Likewise. (dsbt_relocate_main_executable): Likewise. * solib-frv.c (frv_current_sos): Likewise. (frv_relocate_main_executable): Likewise. * solib-spu.c (spu_bfd_fopen): Likewise. * solib-svr4.c (lm_info_read): Likewise. (svr4_copy_library_list): Likewise. (svr4_default_sos): Likewise. * source.c (find_source_lines): Likewise. (line_info): Likewise. (add_substitute_path_rule): Likewise. * spu-linux-nat.c (spu_bfd_open): Likewise. * spu-tdep.c (info_spu_dma_cmdlist): Likewise. * stabsread.c (dbx_lookup_type): Likewise. (read_type): Likewise. (read_member_functions): Likewise. (read_struct_fields): Likewise. (read_baseclasses): Likewise. (read_args): Likewise. (_initialize_stabsread): Likewise. * stack.c (func_command): Likewise. * stap-probe.c (handle_stap_probe): Likewise. * symfile.c (addrs_section_sort): Likewise. (addr_info_make_relative): Likewise. (load_section_callback): Likewise. (add_symbol_file_command): Likewise. (init_filename_language_table): Likewise. * symtab.c (create_filename_seen_cache): Likewise. (sort_search_symbols_remove_dups): Likewise. (search_symbols): Likewise. * target.c (make_cleanup_restore_target_terminal): Likewise. * thread.c (new_thread): Likewise. (enable_thread_stack_temporaries): Likewise. (make_cleanup_restore_current_thread): Likewise. (thread_apply_all_command): Likewise. * tic6x-tdep.c (tic6x_gdbarch_init): Likewise. * top.c (gdb_readline_wrapper): Likewise. * tracefile-tfile.c (tfile_trace_file_writer_new): Likewise. * tracepoint.c (trace_find_line_command): Likewise. (all_tracepoint_actions_and_cleanup): Likewise. (make_cleanup_restore_current_traceframe): Likewise. (get_uploaded_tp): Likewise. (get_uploaded_tsv): Likewise. * tui/tui-data.c (tui_alloc_generic_win_info): Likewise. (tui_alloc_win_info): Likewise. (tui_alloc_content): Likewise. (tui_add_content_elements): Likewise. * tui/tui-disasm.c (tui_find_disassembly_address): Likewise. (tui_set_disassem_content): Likewise. * ui-file.c (ui_file_new): Likewise. (stdio_file_new): Likewise. (tee_file_new): Likewise. * utils.c (make_cleanup_restore_integer): Likewise. (add_internal_problem_command): Likewise. * v850-tdep.c (v850_gdbarch_init): Likewise. * valops.c (find_oload_champ): Likewise. * value.c (allocate_value_lazy): Likewise. (record_latest_value): Likewise. (create_internalvar): Likewise. * varobj.c (install_variable): Likewise. (new_variable): Likewise. (new_root_variable): Likewise. (cppush): Likewise. (_initialize_varobj): Likewise. * windows-nat.c (windows_make_so): Likewise. * x86-nat.c (x86_add_process): Likewise. * xcoffread.c (arrange_linetable): Likewise. (allocate_include_entry): Likewise. (process_linenos): Likewise. (SYMBOL_DUP): Likewise. (xcoff_start_psymtab): Likewise. (xcoff_end_psymtab): Likewise. * xml-support.c (gdb_xml_parse_attr_ulongest): Likewise. * xtensa-tdep.c (xtensa_register_type): Likewise. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. gdb/gdbserver/ChangeLog: * ax.c (gdb_parse_agent_expr): Likewise. (compile_bytecodes): Likewise. * dll.c (loaded_dll): Likewise. * event-loop.c (append_callback_event): Likewise. (create_file_handler): Likewise. (create_file_event): Likewise. * hostio.c (handle_open): Likewise. * inferiors.c (add_thread): Likewise. (add_process): Likewise. * linux-aarch64-low.c (aarch64_linux_new_process): Likewise. * linux-arm-low.c (arm_new_process): Likewise. (arm_new_thread): Likewise. * linux-low.c (add_to_pid_list): Likewise. (linux_add_process): Likewise. (handle_extended_wait): Likewise. (add_lwp): Likewise. (enqueue_one_deferred_signal): Likewise. (enqueue_pending_signal): Likewise. (linux_resume_one_lwp_throw): Likewise. (linux_resume_one_thread): Likewise. (linux_read_memory): Likewise. (linux_write_memory): Likewise. * linux-mips-low.c (mips_linux_new_process): Likewise. (mips_linux_new_thread): Likewise. (mips_add_watchpoint): Likewise. * linux-x86-low.c (initialize_low_arch): Likewise. * lynx-low.c (lynx_add_process): Likewise. * mem-break.c (set_raw_breakpoint_at): Likewise. (set_breakpoint): Likewise. (add_condition_to_breakpoint): Likewise. (add_commands_to_breakpoint): Likewise. (clone_agent_expr): Likewise. (clone_one_breakpoint): Likewise. * regcache.c (new_register_cache): Likewise. * remote-utils.c (look_up_one_symbol): Likewise. * server.c (queue_stop_reply): Likewise. (start_inferior): Likewise. (queue_stop_reply_callback): Likewise. (handle_target_event): Likewise. * spu-low.c (fetch_ppc_memory): Likewise. (store_ppc_memory): Likewise. * target.c (set_target_ops): Likewise. * thread-db.c (thread_db_load_search): Likewise. (try_thread_db_load_1): Likewise. * tracepoint.c (add_tracepoint): Likewise. (add_tracepoint_action): Likewise. (create_trace_state_variable): Likewise. (cmd_qtdpsrc): Likewise. (cmd_qtro): Likewise. (add_while_stepping_state): Likewise. * win32-low.c (child_add_thread): Likewise. (get_image_name): Likewise.
2015-08-26 23:16:07 +02:00
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
SYMBOL_DOMAIN (sym) = UNDEF_DOMAIN;
sym->set_linkage_name (obstack_strndup (&temp_parse_space, name, len));
sym->set_language (language_ada, nullptr);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_exp_elt_opcode (par_state, OP_VAR_VALUE);
write_exp_elt_block (par_state, block);
write_exp_elt_sym (par_state, sym);
write_exp_elt_opcode (par_state, OP_VAR_VALUE);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
}
/* A convenient wrapper around ada_get_field_index that takes
a non NUL-terminated FIELD_NAME0 and a FIELD_NAME_LEN instead
of a NUL-terminated field name. */
static int
ada_nget_field_index (const struct type *type, const char *field_name0,
int field_name_len, int maybe_missing)
{
Add casts to memory allocation related calls Most allocation functions (if not all) return a void* pointing to the allocated memory. In C++, we need to add an explicit cast when assigning the result to a pointer to another type (which is the case more often than not). The content of this patch is taken from Pedro's branch, from commit "(mostly) auto-generated patch to insert casts needed for C++". I validated that the changes make sense and manually reflowed the code to make it respect the coding style. I also found multiple places where I could use XNEW/XNEWVEC/XRESIZEVEC/etc. Thanks a lot to whoever did that automated script to insert casts, doing it completely by hand would have taken a ridiculous amount of time. Only files built on x86 with --enable-targets=all are modified. This means that all other -nat.c files are untouched and will have to be dealt with later by using appropiate compilers. Or maybe we can try to build them with a regular g++ just to know where to add casts, I don't know. I built-tested this with --enable-targets=all and reg-tested. Here's the changelog entry, which was not too bad to make despite the size, thanks to David Malcom's script. I fixed some bits by hand, but there might be some wrong parts left (hopefully not). gdb/ChangeLog: * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Add cast to allocation result assignment. * ada-exp.y (write_object_renaming): Likewise. (write_ambiguous_var): Likewise. (ada_nget_field_index): Likewise. (write_var_or_type): Likewise. * ada-lang.c (ada_decode_symbol): Likewise. (ada_value_assign): Likewise. (value_pointer): Likewise. (cache_symbol): Likewise. (add_nonlocal_symbols): Likewise. (ada_name_for_lookup): Likewise. (symbol_completion_add): Likewise. (ada_to_fixed_type_1): Likewise. (ada_get_next_arg): Likewise. (defns_collected): Likewise. * ada-lex.l (processId): Likewise. (processString): Likewise. * ada-tasks.c (read_known_tasks_array): Likewise. (read_known_tasks_list): Likewise. * ada-typeprint.c (decoded_type_name): Likewise. * addrmap.c (addrmap_mutable_create_fixed): Likewise. * amd64-tdep.c (amd64_push_arguments): Likewise. (amd64_displaced_step_copy_insn): Likewise. (amd64_classify_insn_at): Likewise. (amd64_relocate_instruction): Likewise. * amd64obsd-tdep.c (amd64obsd_sigtramp_p): Likewise. * arch-utils.c (simple_displaced_step_copy_insn): Likewise. (initialize_current_architecture): Likewise. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * arm-symbian-tdep.c (arm_symbian_osabi_sniffer): Likewise. * arm-tdep.c (arm_exidx_new_objfile): Likewise. (arm_push_dummy_call): Likewise. (extend_buffer_earlier): Likewise. (arm_adjust_breakpoint_address): Likewise. (arm_skip_stub): Likewise. * auto-load.c (filename_is_in_pattern): Likewise. (maybe_add_script_file): Likewise. (maybe_add_script_text): Likewise. (auto_load_objfile_script_1): Likewise. * auxv.c (ld_so_xfer_auxv): Likewise. * ax-general.c (new_agent_expr): Likewise. (grow_expr): Likewise. (ax_reg_mask): Likewise. * bcache.c (bcache_full): Likewise. * breakpoint.c (program_breakpoint_here_p): Likewise. * btrace.c (parse_xml_raw): Likewise. * build-id.c (build_id_to_debug_bfd): Likewise. * buildsym.c (end_symtab_with_blockvector): Likewise. * c-exp.y (string_exp): Likewise. (qualified_name): Likewise. (write_destructor_name): Likewise. (operator_stoken): Likewise. (parse_number): Likewise. (scan_macro_expansion): Likewise. (yylex): Likewise. (c_print_token): Likewise. * c-lang.c (c_get_string): Likewise. (emit_numeric_character): Likewise. * charset.c (wchar_iterate): Likewise. * cli/cli-cmds.c (complete_command): Likewise. (make_command): Likewise. * cli/cli-dump.c (restore_section_callback): Likewise. (restore_binary_file): Likewise. * cli/cli-interp.c (cli_interpreter_exec): Likewise. * cli/cli-script.c (execute_control_command): Likewise. * cli/cli-setshow.c (do_set_command): Likewise. * coff-pe-read.c (add_pe_forwarded_sym): Likewise. (read_pe_exported_syms): Likewise. * coffread.c (coff_read_struct_type): Likewise. (coff_read_enum_type): Likewise. * common/btrace-common.c (btrace_data_append): Likewise. * common/buffer.c (buffer_grow): Likewise. * common/filestuff.c (gdb_fopen_cloexec): Likewise. * common/format.c (parse_format_string): Likewise. * common/gdb_vecs.c (delim_string_to_char_ptr_vec_append): Likewise. * common/xml-utils.c (xml_escape_text): Likewise. * compile/compile-object-load.c (copy_sections): Likewise. (compile_object_load): Likewise. * compile/compile-object-run.c (compile_object_run): Likewise. * completer.c (filename_completer): Likewise. * corefile.c (read_memory_typed_address): Likewise. (write_memory_unsigned_integer): Likewise. (write_memory_signed_integer): Likewise. (complete_set_gnutarget): Likewise. * corelow.c (get_core_register_section): Likewise. * cp-name-parser.y (d_grab): Likewise. (allocate_info): Likewise. (cp_new_demangle_parse_info): Likewise. * cp-namespace.c (cp_scan_for_anonymous_namespaces): Likewise. (cp_lookup_symbol_in_namespace): Likewise. (lookup_namespace_scope): Likewise. (find_symbol_in_baseclass): Likewise. (cp_lookup_nested_symbol): Likewise. (cp_lookup_transparent_type_loop): Likewise. * cp-support.c (copy_string_to_obstack): Likewise. (make_symbol_overload_list): Likewise. (make_symbol_overload_list_namespace): Likewise. (make_symbol_overload_list_adl_namespace): Likewise. (first_component_command): Likewise. * cp-valprint.c (cp_print_value): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * d-exp.y (StringExp): Likewise. * d-namespace.c (d_lookup_symbol_in_module): Likewise. (lookup_module_scope): Likewise. (find_symbol_in_baseclass): Likewise. (d_lookup_nested_symbol): Likewise. * dbxread.c (find_stab_function_addr): Likewise. (read_dbx_symtab): Likewise. (dbx_end_psymtab): Likewise. (cp_set_block_scope): Likewise. * dcache.c (dcache_alloc): Likewise. * demangle.c (_initialize_demangler): Likewise. * dicos-tdep.c (dicos_load_module_p): Likewise. * dictionary.c (dict_create_hashed_expandable): Likewise. (dict_create_linear_expandable): Likewise. (expand_hashtable): Likewise. (add_symbol_linear_expandable): Likewise. * dwarf2-frame.c (add_cie): Likewise. (add_fde): Likewise. (dwarf2_build_frame_info): Likewise. * dwarf2expr.c (dwarf_expr_grow_stack): Likewise. (dwarf_expr_fetch_address): Likewise. (add_piece): Likewise. (execute_stack_op): Likewise. * dwarf2loc.c (chain_candidate): Likewise. (dwarf_entry_parameter_to_value): Likewise. (read_pieced_value): Likewise. (write_pieced_value): Likewise. * dwarf2read.c (dwarf2_read_section): Likewise. (add_type_unit): Likewise. (read_comp_units_from_section): Likewise. (fixup_go_packaging): Likewise. (dwarf2_compute_name): Likewise. (dwarf2_physname): Likewise. (create_dwo_unit_in_dwp_v1): Likewise. (create_dwo_unit_in_dwp_v2): Likewise. (read_func_scope): Likewise. (read_call_site_scope): Likewise. (dwarf2_attach_fields_to_type): Likewise. (process_structure_scope): Likewise. (mark_common_block_symbol_computed): Likewise. (read_common_block): Likewise. (abbrev_table_read_table): Likewise. (guess_partial_die_structure_name): Likewise. (fixup_partial_die): Likewise. (add_file_name): Likewise. (dwarf2_const_value_data): Likewise. (dwarf2_const_value_attr): Likewise. (build_error_marker_type): Likewise. (guess_full_die_structure_name): Likewise. (anonymous_struct_prefix): Likewise. (typename_concat): Likewise. (dwarf2_canonicalize_name): Likewise. (dwarf2_name): Likewise. (write_constant_as_bytes): Likewise. (dwarf2_fetch_constant_bytes): Likewise. (copy_string): Likewise. (parse_macro_definition): Likewise. * elfread.c (elf_symfile_segments): Likewise. (elf_rel_plt_read): Likewise. (elf_gnu_ifunc_resolve_by_cache): Likewise. (elf_gnu_ifunc_resolve_by_got): Likewise. (elf_read_minimal_symbols): Likewise. (elf_gnu_ifunc_record_cache): Likewise. * event-top.c (top_level_prompt): Likewise. (command_line_handler): Likewise. * exec.c (resize_section_table): Likewise. * expprint.c (print_subexp_standard): Likewise. * fbsd-tdep.c (fbsd_collect_regset_section_cb): Likewise. * findcmd.c (parse_find_args): Likewise. * findvar.c (address_from_register): Likewise. * frame.c (get_prev_frame_always): Likewise. * gdb_bfd.c (gdb_bfd_ref): Likewise. (get_section_descriptor): Likewise. * gdb_obstack.c (obconcat): Likewise. (obstack_strdup): Likewise. * gdbtypes.c (lookup_function_type_with_arguments): Likewise. (create_set_type): Likewise. (lookup_unsigned_typename): Likewise. (lookup_signed_typename): Likewise. (resolve_dynamic_union): Likewise. (resolve_dynamic_struct): Likewise. (add_dyn_prop): Likewise. (copy_dynamic_prop_list): Likewise. (arch_flags_type): Likewise. (append_composite_type_field_raw): Likewise. * gdbtypes.h (INIT_FUNC_SPECIFIC): Likewise. * gnu-v3-abi.c (gnuv3_rtti_type): Likewise. * go-exp.y (string_exp): Likewise. * go-lang.c (go_demangle): Likewise. * guile/guile.c (compute_scheme_string): Likewise. * guile/scm-cmd.c (gdbscm_parse_command_name): Likewise. (gdbscm_canonicalize_command_name): Likewise. * guile/scm-ports.c (ioscm_init_stdio_buffers): Likewise. (ioscm_init_memory_port): Likewise. (ioscm_reinit_memory_port): Likewise. * guile/scm-utils.c (gdbscm_gc_xstrdup): Likewise. (gdbscm_gc_dup_argv): Likewise. * h8300-tdep.c (h8300_push_dummy_call): Likewise. * hppa-tdep.c (internalize_unwinds): Likewise. (read_unwind_info): Likewise. * i386-cygwin-tdep.c (core_process_module_section): Likewise. (windows_core_xfer_shared_libraries): Likewise. * i386-tdep.c (i386_displaced_step_copy_insn): Likewise. (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * i386obsd-tdep.c (i386obsd_sigtramp_p): Likewise. * inf-child.c (inf_child_fileio_readlink): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. (inf_ptrace_store_register): Likewise. * infrun.c (follow_exec): Likewise. (displaced_step_prepare_throw): Likewise. (save_stop_context): Likewise. (save_infcall_suspend_state): Likewise. * jit.c (jit_read_descriptor): Likewise. (jit_read_code_entry): Likewise. (jit_symtab_line_mapping_add_impl): Likewise. (finalize_symtab): Likewise. (jit_unwind_reg_get_impl): Likewise. * jv-exp.y (QualifiedName): Likewise. * jv-lang.c (get_java_utf8_name): Likewise. (type_from_class): Likewise. (java_demangle_type_signature): Likewise. (java_class_name_from_physname): Likewise. * jv-typeprint.c (java_type_print_base): Likewise. * jv-valprint.c (java_value_print): Likewise. * language.c (add_language): Likewise. * linespec.c (add_sal_to_sals_basic): Likewise. (add_sal_to_sals): Likewise. (decode_objc): Likewise. (find_linespec_symbols): Likewise. * linux-fork.c (fork_save_infrun_state): Likewise. * linux-nat.c (linux_nat_detach): Likewise. (linux_nat_fileio_readlink): Likewise. * linux-record.c (record_linux_sockaddr): Likewise. (record_linux_msghdr): Likewise. (Do): Likewise. * linux-tdep.c (linux_core_info_proc_mappings): Likewise. (linux_collect_regset_section_cb): Likewise. (linux_get_siginfo_data): Likewise. * linux-thread-db.c (try_thread_db_load_from_pdir_1): Likewise. (try_thread_db_load_from_dir): Likewise. (thread_db_load_search): Likewise. (info_auto_load_libthread_db): Likewise. * m32c-tdep.c (m32c_m16c_address_to_pointer): Likewise. (m32c_m16c_pointer_to_address): Likewise. * m68hc11-tdep.c (m68hc11_pseudo_register_write): Likewise. * m68k-tdep.c (m68k_get_longjmp_target): Likewise. * machoread.c (macho_check_dsym): Likewise. * macroexp.c (resize_buffer): Likewise. (gather_arguments): Likewise. (maybe_expand): Likewise. * macrotab.c (new_macro_key): Likewise. (new_source_file): Likewise. (new_macro_definition): Likewise. * mdebugread.c (parse_symbol): Likewise. (parse_type): Likewise. (parse_partial_symbols): Likewise. (psymtab_to_symtab_1): Likewise. * mem-break.c (default_memory_insert_breakpoint): Likewise. * mi/mi-cmd-break.c (mi_argv_to_format): Likewise. * mi/mi-main.c (mi_cmd_data_read_memory): Likewise. (mi_cmd_data_read_memory_bytes): Likewise. (mi_cmd_data_write_memory_bytes): Likewise. (mi_cmd_trace_frame_collected): Likewise. * mi/mi-parse.c (mi_parse_argv): Likewise. (mi_parse): Likewise. * minidebug.c (lzma_open): Likewise. (lzma_pread): Likewise. * mips-tdep.c (mips_read_fp_register_single): Likewise. (mips_print_fp_register): Likewise. * mipsnbsd-tdep.c (mipsnbsd_get_longjmp_target): Likewise. * mipsread.c (read_alphacoff_dynamic_symtab): Likewise. * mt-tdep.c (mt_register_name): Likewise. (mt_registers_info): Likewise. (mt_push_dummy_call): Likewise. * namespace.c (add_using_directive): Likewise. * nat/linux-btrace.c (perf_event_read): Likewise. (linux_enable_bts): Likewise. * nat/linux-osdata.c (linux_common_core_of_thread): Likewise. * nat/linux-ptrace.c (linux_ptrace_test_ret_to_nx): Likewise. * nto-tdep.c (nto_find_and_open_solib): Likewise. (nto_parse_redirection): Likewise. * objc-lang.c (objc_demangle): Likewise. (find_methods): Likewise. * objfiles.c (get_objfile_bfd_data): Likewise. (set_objfile_main_name): Likewise. (allocate_objfile): Likewise. (objfile_relocate): Likewise. (update_section_map): Likewise. * osabi.c (generic_elf_osabi_sniff_abi_tag_sections): Likewise. * p-exp.y (exp): Likewise. (yylex): Likewise. * p-valprint.c (pascal_object_print_value): Likewise. * parse.c (initialize_expout): Likewise. (mark_completion_tag): Likewise. (copy_name): Likewise. (parse_float): Likewise. (type_stack_reserve): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. (ppu2spu_prev_register): Likewise. * ppc-ravenscar-thread.c (supply_register_at_address): Likewise. * printcmd.c (printf_wide_c_string): Likewise. (printf_pointer): Likewise. * probe.c (parse_probes): Likewise. * python/py-cmd.c (gdbpy_parse_command_name): Likewise. (cmdpy_init): Likewise. * python/py-gdb-readline.c (gdbpy_readline_wrapper): Likewise. * python/py-symtab.c (set_sal): Likewise. * python/py-unwind.c (pyuw_sniffer): Likewise. * python/python.c (python_interactive_command): Likewise. (compute_python_string): Likewise. * ravenscar-thread.c (get_running_thread_id): Likewise. * record-full.c (record_full_exec_insn): Likewise. (record_full_core_open_1): Likewise. * regcache.c (regcache_raw_read_signed): Likewise. (regcache_raw_read_unsigned): Likewise. (regcache_cooked_read_signed): Likewise. (regcache_cooked_read_unsigned): Likewise. * remote-fileio.c (remote_fileio_func_open): Likewise. (remote_fileio_func_rename): Likewise. (remote_fileio_func_unlink): Likewise. (remote_fileio_func_stat): Likewise. (remote_fileio_func_system): Likewise. * remote-mips.c (mips_xfer_memory): Likewise. (mips_load_srec): Likewise. (pmon_end_download): Likewise. * remote.c (new_remote_state): Likewise. (map_regcache_remote_table): Likewise. (remote_register_number_and_offset): Likewise. (init_remote_state): Likewise. (get_memory_packet_size): Likewise. (remote_pass_signals): Likewise. (remote_program_signals): Likewise. (remote_start_remote): Likewise. (remote_check_symbols): Likewise. (remote_query_supported): Likewise. (extended_remote_attach): Likewise. (process_g_packet): Likewise. (store_registers_using_G): Likewise. (putpkt_binary): Likewise. (read_frame): Likewise. (compare_sections_command): Likewise. (remote_hostio_pread): Likewise. (remote_hostio_readlink): Likewise. (remote_file_put): Likewise. (remote_file_get): Likewise. (remote_pid_to_exec_file): Likewise. (_initialize_remote): Likewise. * rs6000-aix-tdep.c (rs6000_aix_ld_info_to_xml): Likewise. (rs6000_aix_core_xfer_shared_libraries_aix): Likewise. * rs6000-tdep.c (ppc_displaced_step_copy_insn): Likewise. (bfd_uses_spe_extensions): Likewise. * s390-linux-tdep.c (s390_displaced_step_copy_insn): Likewise. * score-tdep.c (score7_malloc_and_get_memblock): Likewise. * solib-dsbt.c (decode_loadmap): Likewise. (fetch_loadmap): Likewise. (scan_dyntag): Likewise. (enable_break): Likewise. (dsbt_relocate_main_executable): Likewise. * solib-frv.c (fetch_loadmap): Likewise. (enable_break2): Likewise. (frv_relocate_main_executable): Likewise. * solib-spu.c (spu_relocate_main_executable): Likewise. (spu_bfd_open): Likewise. * solib-svr4.c (lm_info_read): Likewise. (read_program_header): Likewise. (find_program_interpreter): Likewise. (scan_dyntag): Likewise. (elf_locate_base): Likewise. (open_symbol_file_object): Likewise. (read_program_headers_from_bfd): Likewise. (svr4_relocate_main_executable): Likewise. * solib-target.c (solib_target_relocate_section_addresses): Likewise. * solib.c (solib_find_1): Likewise. (exec_file_find): Likewise. (solib_find): Likewise. * source.c (openp): Likewise. (print_source_lines_base): Likewise. (forward_search_command): Likewise. * sparc-ravenscar-thread.c (supply_register_at_address): Likewise. * spu-tdep.c (spu2ppu_prev_register): Likewise. (spu_get_overlay_table): Likewise. * stabsread.c (patch_block_stabs): Likewise. (define_symbol): Likewise. (again:): Likewise. (read_member_functions): Likewise. (read_one_struct_field): Likewise. (read_enum_type): Likewise. (common_block_start): Likewise. * stack.c (read_frame_arg): Likewise. (backtrace_command): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. * symfile.c (syms_from_objfile_1): Likewise. (find_separate_debug_file): Likewise. (load_command): Likewise. (load_progress): Likewise. (load_section_callback): Likewise. (reread_symbols): Likewise. (add_filename_language): Likewise. (allocate_compunit_symtab): Likewise. (read_target_long_array): Likewise. (simple_read_overlay_table): Likewise. * symtab.c (symbol_set_names): Likewise. (resize_symbol_cache): Likewise. (rbreak_command): Likewise. (completion_list_add_name): Likewise. (completion_list_objc_symbol): Likewise. (add_filename_to_list): Likewise. * target-descriptions.c (maint_print_c_tdesc_cmd): Likewise. * target-memory.c (target_write_memory_blocks): Likewise. * target.c (target_read_string): Likewise. (read_whatever_is_readable): Likewise. (target_read_alloc_1): Likewise. (simple_search_memory): Likewise. (target_fileio_read_alloc_1): Likewise. * tilegx-tdep.c (tilegx_push_dummy_call): Likewise. * top.c (command_line_input): Likewise. * tracefile-tfile.c (tfile_fetch_registers): Likewise. * tracefile.c (tracefile_fetch_registers): Likewise. * tracepoint.c (add_memrange): Likewise. (init_collection_list): Likewise. (add_aexpr): Likewise. (trace_dump_actions): Likewise. (parse_trace_status): Likewise. (parse_tracepoint_definition): Likewise. (parse_tsv_definition): Likewise. (parse_static_tracepoint_marker_definition): Likewise. * tui/tui-file.c (tui_sfileopen): Likewise. (tui_file_adjust_strbuf): Likewise. * tui/tui-io.c (tui_expand_tabs): Likewise. * tui/tui-source.c (tui_set_source_content): Likewise. * typeprint.c (find_global_typedef): Likewise. * ui-file.c (do_ui_file_xstrdup): Likewise. (ui_file_obsavestring): Likewise. (mem_file_write): Likewise. * utils.c (make_hex_string): Likewise. (get_regcomp_error): Likewise. (puts_filtered_tabular): Likewise. (gdb_realpath_keepfile): Likewise. (ldirname): Likewise. (gdb_bfd_errmsg): Likewise. (substitute_path_component): Likewise. * valops.c (search_struct_method): Likewise. (find_oload_champ_namespace_loop): Likewise. * valprint.c (print_decimal_chars): Likewise. (read_string): Likewise. (generic_emit_char): Likewise. * varobj.c (varobj_delete): Likewise. (varobj_value_get_print_value): Likewise. * vaxobsd-tdep.c (vaxobsd_sigtramp_sniffer): Likewise. * windows-tdep.c (display_one_tib): Likewise. * xcoffread.c (read_xcoff_symtab): Likewise. (process_xcoff_symbol): Likewise. (swap_sym): Likewise. (scan_xcoff_symtab): Likewise. (xcoff_initial_scan): Likewise. * xml-support.c (gdb_xml_end_element): Likewise. (xml_process_xincludes): Likewise. (xml_fetch_content_from_file): Likewise. * xml-syscall.c (xml_list_of_syscalls): Likewise. * xstormy16-tdep.c (xstormy16_push_dummy_call): Likewise. gdb/gdbserver/ChangeLog: * ax.c (gdb_parse_agent_expr): Add cast to allocation result assignment. (gdb_unparse_agent_expr): Likewise. * hostio.c (require_data): Likewise. (handle_pread): Likewise. * linux-low.c (disable_regset): Likewise. (fetch_register): Likewise. (store_register): Likewise. (get_dynamic): Likewise. (linux_qxfer_libraries_svr4): Likewise. * mem-break.c (delete_fast_tracepoint_jump): Likewise. (set_fast_tracepoint_jump): Likewise. (uninsert_fast_tracepoint_jumps_at): Likewise. (reinsert_fast_tracepoint_jumps_at): Likewise. (validate_inserted_breakpoint): Likewise. (clone_agent_expr): Likewise. * regcache.c (init_register_cache): Likewise. * remote-utils.c (putpkt_binary_1): Likewise. (decode_M_packet): Likewise. (decode_X_packet): Likewise. (look_up_one_symbol): Likewise. (relocate_instruction): Likewise. (monitor_output): Likewise. * server.c (handle_search_memory): Likewise. (handle_qxfer_exec_file): Likewise. (handle_qxfer_libraries): Likewise. (handle_qxfer): Likewise. (handle_query): Likewise. (handle_v_cont): Likewise. (handle_v_run): Likewise. (captured_main): Likewise. * target.c (write_inferior_memory): Likewise. * thread-db.c (try_thread_db_load_from_dir): Likewise. * tracepoint.c (init_trace_buffer): Likewise. (add_tracepoint_action): Likewise. (add_traceframe): Likewise. (add_traceframe_block): Likewise. (cmd_qtdpsrc): Likewise. (cmd_qtdv): Likewise. (cmd_qtstatus): Likewise. (response_source): Likewise. (response_tsv): Likewise. (cmd_qtnotes): Likewise. (gdb_collect): Likewise. (initialize_tracepoint): Likewise.
2015-09-25 20:08:06 +02:00
char *field_name = (char *) alloca ((field_name_len + 1) * sizeof (char));
strncpy (field_name, field_name0, field_name_len);
field_name[field_name_len] = '\0';
return ada_get_field_index (type, field_name, maybe_missing);
}
/* If encoded_field_name is the name of a field inside symbol SYM,
then return the type of that field. Otherwise, return NULL.
This function is actually recursive, so if ENCODED_FIELD_NAME
doesn't match one of the fields of our symbol, then try to see
if ENCODED_FIELD_NAME could not be a succession of field names
(in other words, the user entered an expression of the form
TYPE_NAME.FIELD1.FIELD2.FIELD3), in which case we evaluate
each field name sequentially to obtain the desired field type.
In case of failure, we return NULL. */
static struct type *
get_symbol_field_type (struct symbol *sym, char *encoded_field_name)
{
char *field_name = encoded_field_name;
char *subfield_name;
struct type *type = SYMBOL_TYPE (sym);
int fieldno;
if (type == NULL || field_name == NULL)
return NULL;
type = check_typedef (type);
while (field_name[0] != '\0')
{
field_name = chop_separator (field_name);
fieldno = ada_get_field_index (type, field_name, 1);
if (fieldno >= 0)
return TYPE_FIELD_TYPE (type, fieldno);
subfield_name = field_name;
while (*subfield_name != '\0' && *subfield_name != '.'
&& (subfield_name[0] != '_' || subfield_name[1] != '_'))
subfield_name += 1;
if (subfield_name[0] == '\0')
return NULL;
fieldno = ada_nget_field_index (type, field_name,
subfield_name - field_name, 1);
if (fieldno < 0)
return NULL;
type = TYPE_FIELD_TYPE (type, fieldno);
field_name = subfield_name;
}
return NULL;
}
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
/* Look up NAME0 (an unencoded identifier or dotted name) in BLOCK (or
expression_block_context if NULL). If it denotes a type, return
that type. Otherwise, write expression code to evaluate it as an
object and return NULL. In this second case, NAME0 will, in general,
have the form <name>(.<selector_name>)*, where <name> is an object
or renaming encoded in the debugging data. Calls error if no
prefix <name> matches a name in the debugging data (i.e., matches
either a complete name or, as a wild-card match, the final
identifier). */
static struct type*
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_var_or_type (struct parser_state *par_state,
const struct block *block, struct stoken name0)
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
{
int depth;
char *encoded_name;
int name_len;
if (block == NULL)
block = par_state->expression_context_block;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
encoded_name = ada_encode (name0.ptr);
name_len = strlen (encoded_name);
encoded_name = obstack_strndup (&temp_parse_space, encoded_name, name_len);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
for (depth = 0; depth < MAX_RENAMING_CHAIN_LENGTH; depth += 1)
{
int tail_index;
tail_index = name_len;
while (tail_index > 0)
{
int nsyms;
std::vector<struct block_symbol> syms;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
struct symbol *type_sym;
* ada-lang.h (ada_renaming_category): New enumerated type. (ada_lookup_encoded_symbol): Declare. (ada_parse_renaming): Declare. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete declarations. * ada-lang.c (ada_parse_renaming): New function to concentrate extraction of information from renaming symbols. (parse_old_style_renaming): New function to concentrate extraction of old-style (purely type-based) renaming information. (renaming_is_visible): Rename to... (old_renaming_is_invisible): Rename and change sense of renaming_is_visible. (remove_out_of_scope_renamings): Rename to... (remove_irrelevant_renamings): Renames remove_out_of_scope_renamings and augments with additional logic to handle cases where the same object renaming is encoded both as a reference variable and an encoded renaming. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete definitions. (ada_lookup_encoded_symbol): New function factored out of ada_lookup_symbol. (ada_lookup_symbol): Reimplement to call ada_lookup_encoded_symbol. (wild_match): Don't reject perfect match of prefix. (ada_find_renaming_symbol): Factor old-style renaming logic into find_old_style_renaming_symbol. (find_old_style_renaming_symbol): New name for content of old ada_find_renaming_symbol. (ada_prefer_type): Reimplement not to use ada_renaming_type. * ada-exp.y (write_object_renaming): Change interface. Reimplement to use new arguments and ada_parse_renaming. Correct blocks used to find array index. (write_var_or_type): Reimplement to use ada_parse_renaming.
2007-12-21 12:50:11 +01:00
struct symbol *renaming_sym;
const char* renaming;
int renaming_len;
const char* renaming_expr;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
int terminator = encoded_name[tail_index];
encoded_name[tail_index] = '\0';
nsyms = ada_lookup_symbol_list (encoded_name, block,
VAR_DOMAIN, &syms);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
encoded_name[tail_index] = terminator;
type_sym = select_possible_type_sym (syms);
* ada-lang.h (ada_renaming_category): New enumerated type. (ada_lookup_encoded_symbol): Declare. (ada_parse_renaming): Declare. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete declarations. * ada-lang.c (ada_parse_renaming): New function to concentrate extraction of information from renaming symbols. (parse_old_style_renaming): New function to concentrate extraction of old-style (purely type-based) renaming information. (renaming_is_visible): Rename to... (old_renaming_is_invisible): Rename and change sense of renaming_is_visible. (remove_out_of_scope_renamings): Rename to... (remove_irrelevant_renamings): Renames remove_out_of_scope_renamings and augments with additional logic to handle cases where the same object renaming is encoded both as a reference variable and an encoded renaming. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete definitions. (ada_lookup_encoded_symbol): New function factored out of ada_lookup_symbol. (ada_lookup_symbol): Reimplement to call ada_lookup_encoded_symbol. (wild_match): Don't reject perfect match of prefix. (ada_find_renaming_symbol): Factor old-style renaming logic into find_old_style_renaming_symbol. (find_old_style_renaming_symbol): New name for content of old ada_find_renaming_symbol. (ada_prefer_type): Reimplement not to use ada_renaming_type. * ada-exp.y (write_object_renaming): Change interface. Reimplement to use new arguments and ada_parse_renaming. Correct blocks used to find array index. (write_var_or_type): Reimplement to use ada_parse_renaming.
2007-12-21 12:50:11 +01:00
if (type_sym != NULL)
renaming_sym = type_sym;
else if (nsyms == 1)
Replace the block_found global with explicit data-flow As Pedro suggested on gdb-patches@ (see https://sourceware.org/ml/gdb-patches/2015-05/msg00714.html), this change makes symbol lookup functions return a structure that includes both the symbol found and the block in which it was found. This makes it possible to get rid of the block_found global variable and thus makes block hunting explicit. gdb/ * ada-exp.y (write_object_renaming): Replace struct ada_symbol_info with struct block_symbol. Update field references accordingly. (block_lookup, select_possible_type_sym): Likewise. (find_primitive_type): Likewise. Also update call to ada_lookup_symbol to extract the symbol itself. (write_var_or_type, write_name_assoc): Likewise. * ada-lang.h (struct ada_symbol_info): Remove. (ada_lookup_symbol_list): Replace struct ada_symbol_info with struct block_symbol. (ada_lookup_encoded_symbol, user_select_syms): Likewise. (ada_lookup_symbol): Return struct block_symbol instead of a mere symbol. * ada-lang.c (defns_collected): Replace struct ada_symbol_info with struct block_symbol. (resolve_subexp, ada_resolve_function, sort_choices, user_select_syms, is_nonfunction, add_defn_to_vec, num_defns_collected, defns_collected, symbols_are_identical_enums, remove_extra_symbols, remove_irrelevant_renamings, add_lookup_symbol_list_worker, ada_lookup_symbol_list, ada_iterate_over_symbols, ada_lookup_encoded_symbol, get_var_value): Likewise. (ada_lookup_symbol): Return a block_symbol instead of a mere symbol. Replace struct ada_symbol_info with struct block_symbol. (ada_lookup_symbol_nonlocal): Likewise. (standard_lookup): Make block passing explicit through lookup_symbol_in_language. * ada-tasks.c (get_tcb_types_info): Update the calls to lookup_symbol_in_language to extract the mere symbol out of the returned value. (ada_tasks_inferior_data_sniffer): Likewise. * ax-gdb.c (gen_static_field): Likewise for the call to lookup_symbol. (gen_maybe_namespace_elt): Deal with struct symbol_in_block from lookup functions. (gen_expr): Likewise. * c-exp.y: Likewise. Remove uses of block_found. (lex_one_token, classify_inner_name, c_print_token): Likewise. (classify_name): Likewise. Rename the "sym" local variable to "bsym". * c-valprint.c (print_unpacked_pointer): Likewise. * compile/compile-c-symbols.c (convert_symbol_sym): Promote the "sym" parameter from struct symbol * to struct block_symbol. Use it to remove uses of block_found. Deal with struct symbol_in_block from lookup functions. (gcc_convert_symbol): Likewise. Update the call to convert_symbol_sym. * compile/compile-object-load.c (compile_object_load): Deal with struct symbol_in_block from lookup functions. * cp-namespace.c (cp_lookup_nested_symbol_1, cp_lookup_nested_symbol, cp_lookup_bare_symbol, cp_search_static_and_baseclasses, cp_lookup_symbol_in_namespace, cp_lookup_symbol_via_imports, cp_lookup_symbol_imports_or_template, cp_lookup_symbol_via_all_imports, cp_lookup_symbol_namespace, lookup_namespace_scope, cp_lookup_nonlocal, find_symbol_in_baseclass): Return struct symbol_in_block instead of mere symbols and deal with struct symbol_in_block from lookup functions. * cp-support.c (inspect_type, replace_typedefs, cp_lookup_rtti_type): Deal with struct symbol_in_block from lookup functions. * cp-support.h (cp_lookup_symbol_nonlocal, cp_lookup_symbol_from_namespace, cp_lookup_symbol_imports_or_template, cp_lookup_nested_symbol): Return struct symbol_in_block instead of mere symbols. * d-exp.y (d_type_from_name, d_module_from_name, push_variable, push_module_name): Deal with struct symbol_in_block from lookup functions. Remove uses of block_found. * eval.c (evaluate_subexp_standard): Update call to cp_lookup_symbol_namespace. * f-exp.y: Deal with struct symbol_in_block from lookup functions. Remove uses of block_found. (yylex): Likewise. * gdbtypes.c (lookup_typename, lookup_struct, lookup_union, lookup_enum, lookup_template_type, check_typedef): Deal with struct symbol_in_block from lookup functions. * guile/scm-frame.c (gdbscm_frame_read_var): Likewise. * guile/scm-symbol.c (gdbscm_lookup_symbol): Likewise. (gdbscm_lookup_global_symbol): Likewise. * gnu-v3-abi.c (gnuv3_get_typeid_type): Likewise. * go-exp.y: Likewise. Remove uses of block_found. (package_name_p, classify_packaged_name, classify_name): Likewise. * infrun.c (insert_exception_resume_breakpoint): Likewise. * jv-exp.y (push_variable): Likewise. * jv-lang.c (java_lookup_class, get_java_object_type): Likewise. * language.c (language_bool_type): Likewise. * language.h (struct language_defn): Update la_lookup_symbol_nonlocal to return a struct symbol_in_block rather than a mere symbol. * linespec.c (find_label_symbols): Deal with struct symbol_in_block from lookup functions. * m2-exp.y: Likewise. Remove uses of block_found. (yylex): Likewise. * mi/mi-cmd-stack.c (list_args_or_locals): Likewise. * objc-lang.c (lookup_struct_typedef, find_imps): Likewise. * p-exp.y: Likewise. Remove uses of block_found. (yylex): Likewise. * p-valprint.c (pascal_val_print): Likewise. * parse.c (write_dollar_variable): Likewise. Remove uses of block_found. * parser-defs.h (struct symtoken): Turn the SYM field into a struct symbol_in_block. * printcmd.c (address_info): Deal with struct symbol_in_block from lookup functions. * python/py-frame.c (frapy_read_var): Likewise. * python/py-symbol.c (gdbpy_lookup_symbol, gdbpy_lookup_global_symbol): Likewise. * skip.c (skip_function_command): Likewise. * solib-darwin.c (darwin_lookup_lib_symbol): Return a struct symbol_in_block instead of a mere symbol. * solib-spu.c (spu_lookup_lib_symbol): Likewise. * solib-svr4.c (elf_lookup_lib_symbol): Likewise. * solib.c (solib_global_lookup): Likewise. * solist.h (solib_global_lookup): Likewise. (struct target_so_ops): Update lookup_lib_global_symbol to return a struct symbol_in_block rather than a mere symbol. * source.c (select_source_symtab): Deal with struct symbol_in_block from lookup functions. * stack.c (print_frame_args, iterate_over_block_arg_vars): Likewise. * symfile.c (set_initial_language): Likewise. * symtab.c (SYMBOL_LOOKUP_FAILED): Turn into a struct symbol_in_block. (SYMBOL_LOOKUP_FAILED_P): New predicate as a macro. (struct symbol_cache_slot): Turn the FOUND field into a struct symbol_in_block. (block_found): Remove. (eq_symbol_entry): Update to deal with struct symbol_in_block in cache slots. (symbol_cache_lookup): Return a struct symbol_in_block rather than a mere symbol. (symbol_cache_mark_found): Add a BLOCK parameter to fill appropriately the cache slots. Update callers. (symbol_cache_dump): Update cache slots handling to the type change. (lookup_symbol_in_language, lookup_symbol, lookup_language_this, lookup_symbol_aux, lookup_local_symbol, lookup_symbol_in_objfile, lookup_global_symbol_from_objfile, lookup_symbol_in_objfile_symtabs, lookup_symbol_in_objfile_from_linkage_name, lookup_symbol_via_quick_fns, basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block, lookup_static_symbol, lookup_global_symbol): Return a struct symbol_in_block rather than a mere symbol. Deal with struct symbol_in_block from other lookup functions. Remove uses of block_found. (lookup_symbol_in_block): Remove uses of block_found. (struct global_sym_lookup_data): Turn the RESULT field into a struct symbol_in_block. (lookup_symbol_global_iterator_cb): Update references to the RESULT field. (search_symbols): Deal with struct symbol_in_block from lookup functions. * symtab.h (struct symbol_in_block): New structure. (block_found): Remove. (lookup_symbol_in_language, lookup_symbol, basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block, looku_static_symbol, lookup_global_symbol, lookup_symbol_in_block, lookup_language_this, lookup_global_symbol_from_objfile): Return a struct symbol_in_block rather than just a mere symbol. Update comments to remove mentions of block_found. * valops.c (find_function_in_inferior, value_struct_elt_for_reference, value_maybe_namespace_elt, value_of_this): Deal with struct symbol_in_block from lookup functions. * value.c (value_static_field, value_fn_field): Likewise.
2015-07-21 17:02:15 +02:00
renaming_sym = syms[0].symbol;
* ada-lang.h (ada_renaming_category): New enumerated type. (ada_lookup_encoded_symbol): Declare. (ada_parse_renaming): Declare. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete declarations. * ada-lang.c (ada_parse_renaming): New function to concentrate extraction of information from renaming symbols. (parse_old_style_renaming): New function to concentrate extraction of old-style (purely type-based) renaming information. (renaming_is_visible): Rename to... (old_renaming_is_invisible): Rename and change sense of renaming_is_visible. (remove_out_of_scope_renamings): Rename to... (remove_irrelevant_renamings): Renames remove_out_of_scope_renamings and augments with additional logic to handle cases where the same object renaming is encoded both as a reference variable and an encoded renaming. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete definitions. (ada_lookup_encoded_symbol): New function factored out of ada_lookup_symbol. (ada_lookup_symbol): Reimplement to call ada_lookup_encoded_symbol. (wild_match): Don't reject perfect match of prefix. (ada_find_renaming_symbol): Factor old-style renaming logic into find_old_style_renaming_symbol. (find_old_style_renaming_symbol): New name for content of old ada_find_renaming_symbol. (ada_prefer_type): Reimplement not to use ada_renaming_type. * ada-exp.y (write_object_renaming): Change interface. Reimplement to use new arguments and ada_parse_renaming. Correct blocks used to find array index. (write_var_or_type): Reimplement to use ada_parse_renaming.
2007-12-21 12:50:11 +01:00
else
renaming_sym = NULL;
switch (ada_parse_renaming (renaming_sym, &renaming,
&renaming_len, &renaming_expr))
{
case ADA_NOT_RENAMING:
break;
case ADA_PACKAGE_RENAMING:
case ADA_EXCEPTION_RENAMING:
case ADA_SUBPROGRAM_RENAMING:
{
Add casts to memory allocation related calls Most allocation functions (if not all) return a void* pointing to the allocated memory. In C++, we need to add an explicit cast when assigning the result to a pointer to another type (which is the case more often than not). The content of this patch is taken from Pedro's branch, from commit "(mostly) auto-generated patch to insert casts needed for C++". I validated that the changes make sense and manually reflowed the code to make it respect the coding style. I also found multiple places where I could use XNEW/XNEWVEC/XRESIZEVEC/etc. Thanks a lot to whoever did that automated script to insert casts, doing it completely by hand would have taken a ridiculous amount of time. Only files built on x86 with --enable-targets=all are modified. This means that all other -nat.c files are untouched and will have to be dealt with later by using appropiate compilers. Or maybe we can try to build them with a regular g++ just to know where to add casts, I don't know. I built-tested this with --enable-targets=all and reg-tested. Here's the changelog entry, which was not too bad to make despite the size, thanks to David Malcom's script. I fixed some bits by hand, but there might be some wrong parts left (hopefully not). gdb/ChangeLog: * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Add cast to allocation result assignment. * ada-exp.y (write_object_renaming): Likewise. (write_ambiguous_var): Likewise. (ada_nget_field_index): Likewise. (write_var_or_type): Likewise. * ada-lang.c (ada_decode_symbol): Likewise. (ada_value_assign): Likewise. (value_pointer): Likewise. (cache_symbol): Likewise. (add_nonlocal_symbols): Likewise. (ada_name_for_lookup): Likewise. (symbol_completion_add): Likewise. (ada_to_fixed_type_1): Likewise. (ada_get_next_arg): Likewise. (defns_collected): Likewise. * ada-lex.l (processId): Likewise. (processString): Likewise. * ada-tasks.c (read_known_tasks_array): Likewise. (read_known_tasks_list): Likewise. * ada-typeprint.c (decoded_type_name): Likewise. * addrmap.c (addrmap_mutable_create_fixed): Likewise. * amd64-tdep.c (amd64_push_arguments): Likewise. (amd64_displaced_step_copy_insn): Likewise. (amd64_classify_insn_at): Likewise. (amd64_relocate_instruction): Likewise. * amd64obsd-tdep.c (amd64obsd_sigtramp_p): Likewise. * arch-utils.c (simple_displaced_step_copy_insn): Likewise. (initialize_current_architecture): Likewise. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * arm-symbian-tdep.c (arm_symbian_osabi_sniffer): Likewise. * arm-tdep.c (arm_exidx_new_objfile): Likewise. (arm_push_dummy_call): Likewise. (extend_buffer_earlier): Likewise. (arm_adjust_breakpoint_address): Likewise. (arm_skip_stub): Likewise. * auto-load.c (filename_is_in_pattern): Likewise. (maybe_add_script_file): Likewise. (maybe_add_script_text): Likewise. (auto_load_objfile_script_1): Likewise. * auxv.c (ld_so_xfer_auxv): Likewise. * ax-general.c (new_agent_expr): Likewise. (grow_expr): Likewise. (ax_reg_mask): Likewise. * bcache.c (bcache_full): Likewise. * breakpoint.c (program_breakpoint_here_p): Likewise. * btrace.c (parse_xml_raw): Likewise. * build-id.c (build_id_to_debug_bfd): Likewise. * buildsym.c (end_symtab_with_blockvector): Likewise. * c-exp.y (string_exp): Likewise. (qualified_name): Likewise. (write_destructor_name): Likewise. (operator_stoken): Likewise. (parse_number): Likewise. (scan_macro_expansion): Likewise. (yylex): Likewise. (c_print_token): Likewise. * c-lang.c (c_get_string): Likewise. (emit_numeric_character): Likewise. * charset.c (wchar_iterate): Likewise. * cli/cli-cmds.c (complete_command): Likewise. (make_command): Likewise. * cli/cli-dump.c (restore_section_callback): Likewise. (restore_binary_file): Likewise. * cli/cli-interp.c (cli_interpreter_exec): Likewise. * cli/cli-script.c (execute_control_command): Likewise. * cli/cli-setshow.c (do_set_command): Likewise. * coff-pe-read.c (add_pe_forwarded_sym): Likewise. (read_pe_exported_syms): Likewise. * coffread.c (coff_read_struct_type): Likewise. (coff_read_enum_type): Likewise. * common/btrace-common.c (btrace_data_append): Likewise. * common/buffer.c (buffer_grow): Likewise. * common/filestuff.c (gdb_fopen_cloexec): Likewise. * common/format.c (parse_format_string): Likewise. * common/gdb_vecs.c (delim_string_to_char_ptr_vec_append): Likewise. * common/xml-utils.c (xml_escape_text): Likewise. * compile/compile-object-load.c (copy_sections): Likewise. (compile_object_load): Likewise. * compile/compile-object-run.c (compile_object_run): Likewise. * completer.c (filename_completer): Likewise. * corefile.c (read_memory_typed_address): Likewise. (write_memory_unsigned_integer): Likewise. (write_memory_signed_integer): Likewise. (complete_set_gnutarget): Likewise. * corelow.c (get_core_register_section): Likewise. * cp-name-parser.y (d_grab): Likewise. (allocate_info): Likewise. (cp_new_demangle_parse_info): Likewise. * cp-namespace.c (cp_scan_for_anonymous_namespaces): Likewise. (cp_lookup_symbol_in_namespace): Likewise. (lookup_namespace_scope): Likewise. (find_symbol_in_baseclass): Likewise. (cp_lookup_nested_symbol): Likewise. (cp_lookup_transparent_type_loop): Likewise. * cp-support.c (copy_string_to_obstack): Likewise. (make_symbol_overload_list): Likewise. (make_symbol_overload_list_namespace): Likewise. (make_symbol_overload_list_adl_namespace): Likewise. (first_component_command): Likewise. * cp-valprint.c (cp_print_value): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * d-exp.y (StringExp): Likewise. * d-namespace.c (d_lookup_symbol_in_module): Likewise. (lookup_module_scope): Likewise. (find_symbol_in_baseclass): Likewise. (d_lookup_nested_symbol): Likewise. * dbxread.c (find_stab_function_addr): Likewise. (read_dbx_symtab): Likewise. (dbx_end_psymtab): Likewise. (cp_set_block_scope): Likewise. * dcache.c (dcache_alloc): Likewise. * demangle.c (_initialize_demangler): Likewise. * dicos-tdep.c (dicos_load_module_p): Likewise. * dictionary.c (dict_create_hashed_expandable): Likewise. (dict_create_linear_expandable): Likewise. (expand_hashtable): Likewise. (add_symbol_linear_expandable): Likewise. * dwarf2-frame.c (add_cie): Likewise. (add_fde): Likewise. (dwarf2_build_frame_info): Likewise. * dwarf2expr.c (dwarf_expr_grow_stack): Likewise. (dwarf_expr_fetch_address): Likewise. (add_piece): Likewise. (execute_stack_op): Likewise. * dwarf2loc.c (chain_candidate): Likewise. (dwarf_entry_parameter_to_value): Likewise. (read_pieced_value): Likewise. (write_pieced_value): Likewise. * dwarf2read.c (dwarf2_read_section): Likewise. (add_type_unit): Likewise. (read_comp_units_from_section): Likewise. (fixup_go_packaging): Likewise. (dwarf2_compute_name): Likewise. (dwarf2_physname): Likewise. (create_dwo_unit_in_dwp_v1): Likewise. (create_dwo_unit_in_dwp_v2): Likewise. (read_func_scope): Likewise. (read_call_site_scope): Likewise. (dwarf2_attach_fields_to_type): Likewise. (process_structure_scope): Likewise. (mark_common_block_symbol_computed): Likewise. (read_common_block): Likewise. (abbrev_table_read_table): Likewise. (guess_partial_die_structure_name): Likewise. (fixup_partial_die): Likewise. (add_file_name): Likewise. (dwarf2_const_value_data): Likewise. (dwarf2_const_value_attr): Likewise. (build_error_marker_type): Likewise. (guess_full_die_structure_name): Likewise. (anonymous_struct_prefix): Likewise. (typename_concat): Likewise. (dwarf2_canonicalize_name): Likewise. (dwarf2_name): Likewise. (write_constant_as_bytes): Likewise. (dwarf2_fetch_constant_bytes): Likewise. (copy_string): Likewise. (parse_macro_definition): Likewise. * elfread.c (elf_symfile_segments): Likewise. (elf_rel_plt_read): Likewise. (elf_gnu_ifunc_resolve_by_cache): Likewise. (elf_gnu_ifunc_resolve_by_got): Likewise. (elf_read_minimal_symbols): Likewise. (elf_gnu_ifunc_record_cache): Likewise. * event-top.c (top_level_prompt): Likewise. (command_line_handler): Likewise. * exec.c (resize_section_table): Likewise. * expprint.c (print_subexp_standard): Likewise. * fbsd-tdep.c (fbsd_collect_regset_section_cb): Likewise. * findcmd.c (parse_find_args): Likewise. * findvar.c (address_from_register): Likewise. * frame.c (get_prev_frame_always): Likewise. * gdb_bfd.c (gdb_bfd_ref): Likewise. (get_section_descriptor): Likewise. * gdb_obstack.c (obconcat): Likewise. (obstack_strdup): Likewise. * gdbtypes.c (lookup_function_type_with_arguments): Likewise. (create_set_type): Likewise. (lookup_unsigned_typename): Likewise. (lookup_signed_typename): Likewise. (resolve_dynamic_union): Likewise. (resolve_dynamic_struct): Likewise. (add_dyn_prop): Likewise. (copy_dynamic_prop_list): Likewise. (arch_flags_type): Likewise. (append_composite_type_field_raw): Likewise. * gdbtypes.h (INIT_FUNC_SPECIFIC): Likewise. * gnu-v3-abi.c (gnuv3_rtti_type): Likewise. * go-exp.y (string_exp): Likewise. * go-lang.c (go_demangle): Likewise. * guile/guile.c (compute_scheme_string): Likewise. * guile/scm-cmd.c (gdbscm_parse_command_name): Likewise. (gdbscm_canonicalize_command_name): Likewise. * guile/scm-ports.c (ioscm_init_stdio_buffers): Likewise. (ioscm_init_memory_port): Likewise. (ioscm_reinit_memory_port): Likewise. * guile/scm-utils.c (gdbscm_gc_xstrdup): Likewise. (gdbscm_gc_dup_argv): Likewise. * h8300-tdep.c (h8300_push_dummy_call): Likewise. * hppa-tdep.c (internalize_unwinds): Likewise. (read_unwind_info): Likewise. * i386-cygwin-tdep.c (core_process_module_section): Likewise. (windows_core_xfer_shared_libraries): Likewise. * i386-tdep.c (i386_displaced_step_copy_insn): Likewise. (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * i386obsd-tdep.c (i386obsd_sigtramp_p): Likewise. * inf-child.c (inf_child_fileio_readlink): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. (inf_ptrace_store_register): Likewise. * infrun.c (follow_exec): Likewise. (displaced_step_prepare_throw): Likewise. (save_stop_context): Likewise. (save_infcall_suspend_state): Likewise. * jit.c (jit_read_descriptor): Likewise. (jit_read_code_entry): Likewise. (jit_symtab_line_mapping_add_impl): Likewise. (finalize_symtab): Likewise. (jit_unwind_reg_get_impl): Likewise. * jv-exp.y (QualifiedName): Likewise. * jv-lang.c (get_java_utf8_name): Likewise. (type_from_class): Likewise. (java_demangle_type_signature): Likewise. (java_class_name_from_physname): Likewise. * jv-typeprint.c (java_type_print_base): Likewise. * jv-valprint.c (java_value_print): Likewise. * language.c (add_language): Likewise. * linespec.c (add_sal_to_sals_basic): Likewise. (add_sal_to_sals): Likewise. (decode_objc): Likewise. (find_linespec_symbols): Likewise. * linux-fork.c (fork_save_infrun_state): Likewise. * linux-nat.c (linux_nat_detach): Likewise. (linux_nat_fileio_readlink): Likewise. * linux-record.c (record_linux_sockaddr): Likewise. (record_linux_msghdr): Likewise. (Do): Likewise. * linux-tdep.c (linux_core_info_proc_mappings): Likewise. (linux_collect_regset_section_cb): Likewise. (linux_get_siginfo_data): Likewise. * linux-thread-db.c (try_thread_db_load_from_pdir_1): Likewise. (try_thread_db_load_from_dir): Likewise. (thread_db_load_search): Likewise. (info_auto_load_libthread_db): Likewise. * m32c-tdep.c (m32c_m16c_address_to_pointer): Likewise. (m32c_m16c_pointer_to_address): Likewise. * m68hc11-tdep.c (m68hc11_pseudo_register_write): Likewise. * m68k-tdep.c (m68k_get_longjmp_target): Likewise. * machoread.c (macho_check_dsym): Likewise. * macroexp.c (resize_buffer): Likewise. (gather_arguments): Likewise. (maybe_expand): Likewise. * macrotab.c (new_macro_key): Likewise. (new_source_file): Likewise. (new_macro_definition): Likewise. * mdebugread.c (parse_symbol): Likewise. (parse_type): Likewise. (parse_partial_symbols): Likewise. (psymtab_to_symtab_1): Likewise. * mem-break.c (default_memory_insert_breakpoint): Likewise. * mi/mi-cmd-break.c (mi_argv_to_format): Likewise. * mi/mi-main.c (mi_cmd_data_read_memory): Likewise. (mi_cmd_data_read_memory_bytes): Likewise. (mi_cmd_data_write_memory_bytes): Likewise. (mi_cmd_trace_frame_collected): Likewise. * mi/mi-parse.c (mi_parse_argv): Likewise. (mi_parse): Likewise. * minidebug.c (lzma_open): Likewise. (lzma_pread): Likewise. * mips-tdep.c (mips_read_fp_register_single): Likewise. (mips_print_fp_register): Likewise. * mipsnbsd-tdep.c (mipsnbsd_get_longjmp_target): Likewise. * mipsread.c (read_alphacoff_dynamic_symtab): Likewise. * mt-tdep.c (mt_register_name): Likewise. (mt_registers_info): Likewise. (mt_push_dummy_call): Likewise. * namespace.c (add_using_directive): Likewise. * nat/linux-btrace.c (perf_event_read): Likewise. (linux_enable_bts): Likewise. * nat/linux-osdata.c (linux_common_core_of_thread): Likewise. * nat/linux-ptrace.c (linux_ptrace_test_ret_to_nx): Likewise. * nto-tdep.c (nto_find_and_open_solib): Likewise. (nto_parse_redirection): Likewise. * objc-lang.c (objc_demangle): Likewise. (find_methods): Likewise. * objfiles.c (get_objfile_bfd_data): Likewise. (set_objfile_main_name): Likewise. (allocate_objfile): Likewise. (objfile_relocate): Likewise. (update_section_map): Likewise. * osabi.c (generic_elf_osabi_sniff_abi_tag_sections): Likewise. * p-exp.y (exp): Likewise. (yylex): Likewise. * p-valprint.c (pascal_object_print_value): Likewise. * parse.c (initialize_expout): Likewise. (mark_completion_tag): Likewise. (copy_name): Likewise. (parse_float): Likewise. (type_stack_reserve): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. (ppu2spu_prev_register): Likewise. * ppc-ravenscar-thread.c (supply_register_at_address): Likewise. * printcmd.c (printf_wide_c_string): Likewise. (printf_pointer): Likewise. * probe.c (parse_probes): Likewise. * python/py-cmd.c (gdbpy_parse_command_name): Likewise. (cmdpy_init): Likewise. * python/py-gdb-readline.c (gdbpy_readline_wrapper): Likewise. * python/py-symtab.c (set_sal): Likewise. * python/py-unwind.c (pyuw_sniffer): Likewise. * python/python.c (python_interactive_command): Likewise. (compute_python_string): Likewise. * ravenscar-thread.c (get_running_thread_id): Likewise. * record-full.c (record_full_exec_insn): Likewise. (record_full_core_open_1): Likewise. * regcache.c (regcache_raw_read_signed): Likewise. (regcache_raw_read_unsigned): Likewise. (regcache_cooked_read_signed): Likewise. (regcache_cooked_read_unsigned): Likewise. * remote-fileio.c (remote_fileio_func_open): Likewise. (remote_fileio_func_rename): Likewise. (remote_fileio_func_unlink): Likewise. (remote_fileio_func_stat): Likewise. (remote_fileio_func_system): Likewise. * remote-mips.c (mips_xfer_memory): Likewise. (mips_load_srec): Likewise. (pmon_end_download): Likewise. * remote.c (new_remote_state): Likewise. (map_regcache_remote_table): Likewise. (remote_register_number_and_offset): Likewise. (init_remote_state): Likewise. (get_memory_packet_size): Likewise. (remote_pass_signals): Likewise. (remote_program_signals): Likewise. (remote_start_remote): Likewise. (remote_check_symbols): Likewise. (remote_query_supported): Likewise. (extended_remote_attach): Likewise. (process_g_packet): Likewise. (store_registers_using_G): Likewise. (putpkt_binary): Likewise. (read_frame): Likewise. (compare_sections_command): Likewise. (remote_hostio_pread): Likewise. (remote_hostio_readlink): Likewise. (remote_file_put): Likewise. (remote_file_get): Likewise. (remote_pid_to_exec_file): Likewise. (_initialize_remote): Likewise. * rs6000-aix-tdep.c (rs6000_aix_ld_info_to_xml): Likewise. (rs6000_aix_core_xfer_shared_libraries_aix): Likewise. * rs6000-tdep.c (ppc_displaced_step_copy_insn): Likewise. (bfd_uses_spe_extensions): Likewise. * s390-linux-tdep.c (s390_displaced_step_copy_insn): Likewise. * score-tdep.c (score7_malloc_and_get_memblock): Likewise. * solib-dsbt.c (decode_loadmap): Likewise. (fetch_loadmap): Likewise. (scan_dyntag): Likewise. (enable_break): Likewise. (dsbt_relocate_main_executable): Likewise. * solib-frv.c (fetch_loadmap): Likewise. (enable_break2): Likewise. (frv_relocate_main_executable): Likewise. * solib-spu.c (spu_relocate_main_executable): Likewise. (spu_bfd_open): Likewise. * solib-svr4.c (lm_info_read): Likewise. (read_program_header): Likewise. (find_program_interpreter): Likewise. (scan_dyntag): Likewise. (elf_locate_base): Likewise. (open_symbol_file_object): Likewise. (read_program_headers_from_bfd): Likewise. (svr4_relocate_main_executable): Likewise. * solib-target.c (solib_target_relocate_section_addresses): Likewise. * solib.c (solib_find_1): Likewise. (exec_file_find): Likewise. (solib_find): Likewise. * source.c (openp): Likewise. (print_source_lines_base): Likewise. (forward_search_command): Likewise. * sparc-ravenscar-thread.c (supply_register_at_address): Likewise. * spu-tdep.c (spu2ppu_prev_register): Likewise. (spu_get_overlay_table): Likewise. * stabsread.c (patch_block_stabs): Likewise. (define_symbol): Likewise. (again:): Likewise. (read_member_functions): Likewise. (read_one_struct_field): Likewise. (read_enum_type): Likewise. (common_block_start): Likewise. * stack.c (read_frame_arg): Likewise. (backtrace_command): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. * symfile.c (syms_from_objfile_1): Likewise. (find_separate_debug_file): Likewise. (load_command): Likewise. (load_progress): Likewise. (load_section_callback): Likewise. (reread_symbols): Likewise. (add_filename_language): Likewise. (allocate_compunit_symtab): Likewise. (read_target_long_array): Likewise. (simple_read_overlay_table): Likewise. * symtab.c (symbol_set_names): Likewise. (resize_symbol_cache): Likewise. (rbreak_command): Likewise. (completion_list_add_name): Likewise. (completion_list_objc_symbol): Likewise. (add_filename_to_list): Likewise. * target-descriptions.c (maint_print_c_tdesc_cmd): Likewise. * target-memory.c (target_write_memory_blocks): Likewise. * target.c (target_read_string): Likewise. (read_whatever_is_readable): Likewise. (target_read_alloc_1): Likewise. (simple_search_memory): Likewise. (target_fileio_read_alloc_1): Likewise. * tilegx-tdep.c (tilegx_push_dummy_call): Likewise. * top.c (command_line_input): Likewise. * tracefile-tfile.c (tfile_fetch_registers): Likewise. * tracefile.c (tracefile_fetch_registers): Likewise. * tracepoint.c (add_memrange): Likewise. (init_collection_list): Likewise. (add_aexpr): Likewise. (trace_dump_actions): Likewise. (parse_trace_status): Likewise. (parse_tracepoint_definition): Likewise. (parse_tsv_definition): Likewise. (parse_static_tracepoint_marker_definition): Likewise. * tui/tui-file.c (tui_sfileopen): Likewise. (tui_file_adjust_strbuf): Likewise. * tui/tui-io.c (tui_expand_tabs): Likewise. * tui/tui-source.c (tui_set_source_content): Likewise. * typeprint.c (find_global_typedef): Likewise. * ui-file.c (do_ui_file_xstrdup): Likewise. (ui_file_obsavestring): Likewise. (mem_file_write): Likewise. * utils.c (make_hex_string): Likewise. (get_regcomp_error): Likewise. (puts_filtered_tabular): Likewise. (gdb_realpath_keepfile): Likewise. (ldirname): Likewise. (gdb_bfd_errmsg): Likewise. (substitute_path_component): Likewise. * valops.c (search_struct_method): Likewise. (find_oload_champ_namespace_loop): Likewise. * valprint.c (print_decimal_chars): Likewise. (read_string): Likewise. (generic_emit_char): Likewise. * varobj.c (varobj_delete): Likewise. (varobj_value_get_print_value): Likewise. * vaxobsd-tdep.c (vaxobsd_sigtramp_sniffer): Likewise. * windows-tdep.c (display_one_tib): Likewise. * xcoffread.c (read_xcoff_symtab): Likewise. (process_xcoff_symbol): Likewise. (swap_sym): Likewise. (scan_xcoff_symtab): Likewise. (xcoff_initial_scan): Likewise. * xml-support.c (gdb_xml_end_element): Likewise. (xml_process_xincludes): Likewise. (xml_fetch_content_from_file): Likewise. * xml-syscall.c (xml_list_of_syscalls): Likewise. * xstormy16-tdep.c (xstormy16_push_dummy_call): Likewise. gdb/gdbserver/ChangeLog: * ax.c (gdb_parse_agent_expr): Add cast to allocation result assignment. (gdb_unparse_agent_expr): Likewise. * hostio.c (require_data): Likewise. (handle_pread): Likewise. * linux-low.c (disable_regset): Likewise. (fetch_register): Likewise. (store_register): Likewise. (get_dynamic): Likewise. (linux_qxfer_libraries_svr4): Likewise. * mem-break.c (delete_fast_tracepoint_jump): Likewise. (set_fast_tracepoint_jump): Likewise. (uninsert_fast_tracepoint_jumps_at): Likewise. (reinsert_fast_tracepoint_jumps_at): Likewise. (validate_inserted_breakpoint): Likewise. (clone_agent_expr): Likewise. * regcache.c (init_register_cache): Likewise. * remote-utils.c (putpkt_binary_1): Likewise. (decode_M_packet): Likewise. (decode_X_packet): Likewise. (look_up_one_symbol): Likewise. (relocate_instruction): Likewise. (monitor_output): Likewise. * server.c (handle_search_memory): Likewise. (handle_qxfer_exec_file): Likewise. (handle_qxfer_libraries): Likewise. (handle_qxfer): Likewise. (handle_query): Likewise. (handle_v_cont): Likewise. (handle_v_run): Likewise. (captured_main): Likewise. * target.c (write_inferior_memory): Likewise. * thread-db.c (try_thread_db_load_from_dir): Likewise. * tracepoint.c (init_trace_buffer): Likewise. (add_tracepoint_action): Likewise. (add_traceframe): Likewise. (add_traceframe_block): Likewise. (cmd_qtdpsrc): Likewise. (cmd_qtdv): Likewise. (cmd_qtstatus): Likewise. (response_source): Likewise. (response_tsv): Likewise. (cmd_qtnotes): Likewise. (gdb_collect): Likewise. (initialize_tracepoint): Likewise.
2015-09-25 20:08:06 +02:00
int alloc_len = renaming_len + name_len - tail_index + 1;
* ada-lang.h (ada_renaming_category): New enumerated type. (ada_lookup_encoded_symbol): Declare. (ada_parse_renaming): Declare. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete declarations. * ada-lang.c (ada_parse_renaming): New function to concentrate extraction of information from renaming symbols. (parse_old_style_renaming): New function to concentrate extraction of old-style (purely type-based) renaming information. (renaming_is_visible): Rename to... (old_renaming_is_invisible): Rename and change sense of renaming_is_visible. (remove_out_of_scope_renamings): Rename to... (remove_irrelevant_renamings): Renames remove_out_of_scope_renamings and augments with additional logic to handle cases where the same object renaming is encoded both as a reference variable and an encoded renaming. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete definitions. (ada_lookup_encoded_symbol): New function factored out of ada_lookup_symbol. (ada_lookup_symbol): Reimplement to call ada_lookup_encoded_symbol. (wild_match): Don't reject perfect match of prefix. (ada_find_renaming_symbol): Factor old-style renaming logic into find_old_style_renaming_symbol. (find_old_style_renaming_symbol): New name for content of old ada_find_renaming_symbol. (ada_prefer_type): Reimplement not to use ada_renaming_type. * ada-exp.y (write_object_renaming): Change interface. Reimplement to use new arguments and ada_parse_renaming. Correct blocks used to find array index. (write_var_or_type): Reimplement to use ada_parse_renaming.
2007-12-21 12:50:11 +01:00
char *new_name
Add casts to memory allocation related calls Most allocation functions (if not all) return a void* pointing to the allocated memory. In C++, we need to add an explicit cast when assigning the result to a pointer to another type (which is the case more often than not). The content of this patch is taken from Pedro's branch, from commit "(mostly) auto-generated patch to insert casts needed for C++". I validated that the changes make sense and manually reflowed the code to make it respect the coding style. I also found multiple places where I could use XNEW/XNEWVEC/XRESIZEVEC/etc. Thanks a lot to whoever did that automated script to insert casts, doing it completely by hand would have taken a ridiculous amount of time. Only files built on x86 with --enable-targets=all are modified. This means that all other -nat.c files are untouched and will have to be dealt with later by using appropiate compilers. Or maybe we can try to build them with a regular g++ just to know where to add casts, I don't know. I built-tested this with --enable-targets=all and reg-tested. Here's the changelog entry, which was not too bad to make despite the size, thanks to David Malcom's script. I fixed some bits by hand, but there might be some wrong parts left (hopefully not). gdb/ChangeLog: * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Add cast to allocation result assignment. * ada-exp.y (write_object_renaming): Likewise. (write_ambiguous_var): Likewise. (ada_nget_field_index): Likewise. (write_var_or_type): Likewise. * ada-lang.c (ada_decode_symbol): Likewise. (ada_value_assign): Likewise. (value_pointer): Likewise. (cache_symbol): Likewise. (add_nonlocal_symbols): Likewise. (ada_name_for_lookup): Likewise. (symbol_completion_add): Likewise. (ada_to_fixed_type_1): Likewise. (ada_get_next_arg): Likewise. (defns_collected): Likewise. * ada-lex.l (processId): Likewise. (processString): Likewise. * ada-tasks.c (read_known_tasks_array): Likewise. (read_known_tasks_list): Likewise. * ada-typeprint.c (decoded_type_name): Likewise. * addrmap.c (addrmap_mutable_create_fixed): Likewise. * amd64-tdep.c (amd64_push_arguments): Likewise. (amd64_displaced_step_copy_insn): Likewise. (amd64_classify_insn_at): Likewise. (amd64_relocate_instruction): Likewise. * amd64obsd-tdep.c (amd64obsd_sigtramp_p): Likewise. * arch-utils.c (simple_displaced_step_copy_insn): Likewise. (initialize_current_architecture): Likewise. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * arm-symbian-tdep.c (arm_symbian_osabi_sniffer): Likewise. * arm-tdep.c (arm_exidx_new_objfile): Likewise. (arm_push_dummy_call): Likewise. (extend_buffer_earlier): Likewise. (arm_adjust_breakpoint_address): Likewise. (arm_skip_stub): Likewise. * auto-load.c (filename_is_in_pattern): Likewise. (maybe_add_script_file): Likewise. (maybe_add_script_text): Likewise. (auto_load_objfile_script_1): Likewise. * auxv.c (ld_so_xfer_auxv): Likewise. * ax-general.c (new_agent_expr): Likewise. (grow_expr): Likewise. (ax_reg_mask): Likewise. * bcache.c (bcache_full): Likewise. * breakpoint.c (program_breakpoint_here_p): Likewise. * btrace.c (parse_xml_raw): Likewise. * build-id.c (build_id_to_debug_bfd): Likewise. * buildsym.c (end_symtab_with_blockvector): Likewise. * c-exp.y (string_exp): Likewise. (qualified_name): Likewise. (write_destructor_name): Likewise. (operator_stoken): Likewise. (parse_number): Likewise. (scan_macro_expansion): Likewise. (yylex): Likewise. (c_print_token): Likewise. * c-lang.c (c_get_string): Likewise. (emit_numeric_character): Likewise. * charset.c (wchar_iterate): Likewise. * cli/cli-cmds.c (complete_command): Likewise. (make_command): Likewise. * cli/cli-dump.c (restore_section_callback): Likewise. (restore_binary_file): Likewise. * cli/cli-interp.c (cli_interpreter_exec): Likewise. * cli/cli-script.c (execute_control_command): Likewise. * cli/cli-setshow.c (do_set_command): Likewise. * coff-pe-read.c (add_pe_forwarded_sym): Likewise. (read_pe_exported_syms): Likewise. * coffread.c (coff_read_struct_type): Likewise. (coff_read_enum_type): Likewise. * common/btrace-common.c (btrace_data_append): Likewise. * common/buffer.c (buffer_grow): Likewise. * common/filestuff.c (gdb_fopen_cloexec): Likewise. * common/format.c (parse_format_string): Likewise. * common/gdb_vecs.c (delim_string_to_char_ptr_vec_append): Likewise. * common/xml-utils.c (xml_escape_text): Likewise. * compile/compile-object-load.c (copy_sections): Likewise. (compile_object_load): Likewise. * compile/compile-object-run.c (compile_object_run): Likewise. * completer.c (filename_completer): Likewise. * corefile.c (read_memory_typed_address): Likewise. (write_memory_unsigned_integer): Likewise. (write_memory_signed_integer): Likewise. (complete_set_gnutarget): Likewise. * corelow.c (get_core_register_section): Likewise. * cp-name-parser.y (d_grab): Likewise. (allocate_info): Likewise. (cp_new_demangle_parse_info): Likewise. * cp-namespace.c (cp_scan_for_anonymous_namespaces): Likewise. (cp_lookup_symbol_in_namespace): Likewise. (lookup_namespace_scope): Likewise. (find_symbol_in_baseclass): Likewise. (cp_lookup_nested_symbol): Likewise. (cp_lookup_transparent_type_loop): Likewise. * cp-support.c (copy_string_to_obstack): Likewise. (make_symbol_overload_list): Likewise. (make_symbol_overload_list_namespace): Likewise. (make_symbol_overload_list_adl_namespace): Likewise. (first_component_command): Likewise. * cp-valprint.c (cp_print_value): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * d-exp.y (StringExp): Likewise. * d-namespace.c (d_lookup_symbol_in_module): Likewise. (lookup_module_scope): Likewise. (find_symbol_in_baseclass): Likewise. (d_lookup_nested_symbol): Likewise. * dbxread.c (find_stab_function_addr): Likewise. (read_dbx_symtab): Likewise. (dbx_end_psymtab): Likewise. (cp_set_block_scope): Likewise. * dcache.c (dcache_alloc): Likewise. * demangle.c (_initialize_demangler): Likewise. * dicos-tdep.c (dicos_load_module_p): Likewise. * dictionary.c (dict_create_hashed_expandable): Likewise. (dict_create_linear_expandable): Likewise. (expand_hashtable): Likewise. (add_symbol_linear_expandable): Likewise. * dwarf2-frame.c (add_cie): Likewise. (add_fde): Likewise. (dwarf2_build_frame_info): Likewise. * dwarf2expr.c (dwarf_expr_grow_stack): Likewise. (dwarf_expr_fetch_address): Likewise. (add_piece): Likewise. (execute_stack_op): Likewise. * dwarf2loc.c (chain_candidate): Likewise. (dwarf_entry_parameter_to_value): Likewise. (read_pieced_value): Likewise. (write_pieced_value): Likewise. * dwarf2read.c (dwarf2_read_section): Likewise. (add_type_unit): Likewise. (read_comp_units_from_section): Likewise. (fixup_go_packaging): Likewise. (dwarf2_compute_name): Likewise. (dwarf2_physname): Likewise. (create_dwo_unit_in_dwp_v1): Likewise. (create_dwo_unit_in_dwp_v2): Likewise. (read_func_scope): Likewise. (read_call_site_scope): Likewise. (dwarf2_attach_fields_to_type): Likewise. (process_structure_scope): Likewise. (mark_common_block_symbol_computed): Likewise. (read_common_block): Likewise. (abbrev_table_read_table): Likewise. (guess_partial_die_structure_name): Likewise. (fixup_partial_die): Likewise. (add_file_name): Likewise. (dwarf2_const_value_data): Likewise. (dwarf2_const_value_attr): Likewise. (build_error_marker_type): Likewise. (guess_full_die_structure_name): Likewise. (anonymous_struct_prefix): Likewise. (typename_concat): Likewise. (dwarf2_canonicalize_name): Likewise. (dwarf2_name): Likewise. (write_constant_as_bytes): Likewise. (dwarf2_fetch_constant_bytes): Likewise. (copy_string): Likewise. (parse_macro_definition): Likewise. * elfread.c (elf_symfile_segments): Likewise. (elf_rel_plt_read): Likewise. (elf_gnu_ifunc_resolve_by_cache): Likewise. (elf_gnu_ifunc_resolve_by_got): Likewise. (elf_read_minimal_symbols): Likewise. (elf_gnu_ifunc_record_cache): Likewise. * event-top.c (top_level_prompt): Likewise. (command_line_handler): Likewise. * exec.c (resize_section_table): Likewise. * expprint.c (print_subexp_standard): Likewise. * fbsd-tdep.c (fbsd_collect_regset_section_cb): Likewise. * findcmd.c (parse_find_args): Likewise. * findvar.c (address_from_register): Likewise. * frame.c (get_prev_frame_always): Likewise. * gdb_bfd.c (gdb_bfd_ref): Likewise. (get_section_descriptor): Likewise. * gdb_obstack.c (obconcat): Likewise. (obstack_strdup): Likewise. * gdbtypes.c (lookup_function_type_with_arguments): Likewise. (create_set_type): Likewise. (lookup_unsigned_typename): Likewise. (lookup_signed_typename): Likewise. (resolve_dynamic_union): Likewise. (resolve_dynamic_struct): Likewise. (add_dyn_prop): Likewise. (copy_dynamic_prop_list): Likewise. (arch_flags_type): Likewise. (append_composite_type_field_raw): Likewise. * gdbtypes.h (INIT_FUNC_SPECIFIC): Likewise. * gnu-v3-abi.c (gnuv3_rtti_type): Likewise. * go-exp.y (string_exp): Likewise. * go-lang.c (go_demangle): Likewise. * guile/guile.c (compute_scheme_string): Likewise. * guile/scm-cmd.c (gdbscm_parse_command_name): Likewise. (gdbscm_canonicalize_command_name): Likewise. * guile/scm-ports.c (ioscm_init_stdio_buffers): Likewise. (ioscm_init_memory_port): Likewise. (ioscm_reinit_memory_port): Likewise. * guile/scm-utils.c (gdbscm_gc_xstrdup): Likewise. (gdbscm_gc_dup_argv): Likewise. * h8300-tdep.c (h8300_push_dummy_call): Likewise. * hppa-tdep.c (internalize_unwinds): Likewise. (read_unwind_info): Likewise. * i386-cygwin-tdep.c (core_process_module_section): Likewise. (windows_core_xfer_shared_libraries): Likewise. * i386-tdep.c (i386_displaced_step_copy_insn): Likewise. (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * i386obsd-tdep.c (i386obsd_sigtramp_p): Likewise. * inf-child.c (inf_child_fileio_readlink): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. (inf_ptrace_store_register): Likewise. * infrun.c (follow_exec): Likewise. (displaced_step_prepare_throw): Likewise. (save_stop_context): Likewise. (save_infcall_suspend_state): Likewise. * jit.c (jit_read_descriptor): Likewise. (jit_read_code_entry): Likewise. (jit_symtab_line_mapping_add_impl): Likewise. (finalize_symtab): Likewise. (jit_unwind_reg_get_impl): Likewise. * jv-exp.y (QualifiedName): Likewise. * jv-lang.c (get_java_utf8_name): Likewise. (type_from_class): Likewise. (java_demangle_type_signature): Likewise. (java_class_name_from_physname): Likewise. * jv-typeprint.c (java_type_print_base): Likewise. * jv-valprint.c (java_value_print): Likewise. * language.c (add_language): Likewise. * linespec.c (add_sal_to_sals_basic): Likewise. (add_sal_to_sals): Likewise. (decode_objc): Likewise. (find_linespec_symbols): Likewise. * linux-fork.c (fork_save_infrun_state): Likewise. * linux-nat.c (linux_nat_detach): Likewise. (linux_nat_fileio_readlink): Likewise. * linux-record.c (record_linux_sockaddr): Likewise. (record_linux_msghdr): Likewise. (Do): Likewise. * linux-tdep.c (linux_core_info_proc_mappings): Likewise. (linux_collect_regset_section_cb): Likewise. (linux_get_siginfo_data): Likewise. * linux-thread-db.c (try_thread_db_load_from_pdir_1): Likewise. (try_thread_db_load_from_dir): Likewise. (thread_db_load_search): Likewise. (info_auto_load_libthread_db): Likewise. * m32c-tdep.c (m32c_m16c_address_to_pointer): Likewise. (m32c_m16c_pointer_to_address): Likewise. * m68hc11-tdep.c (m68hc11_pseudo_register_write): Likewise. * m68k-tdep.c (m68k_get_longjmp_target): Likewise. * machoread.c (macho_check_dsym): Likewise. * macroexp.c (resize_buffer): Likewise. (gather_arguments): Likewise. (maybe_expand): Likewise. * macrotab.c (new_macro_key): Likewise. (new_source_file): Likewise. (new_macro_definition): Likewise. * mdebugread.c (parse_symbol): Likewise. (parse_type): Likewise. (parse_partial_symbols): Likewise. (psymtab_to_symtab_1): Likewise. * mem-break.c (default_memory_insert_breakpoint): Likewise. * mi/mi-cmd-break.c (mi_argv_to_format): Likewise. * mi/mi-main.c (mi_cmd_data_read_memory): Likewise. (mi_cmd_data_read_memory_bytes): Likewise. (mi_cmd_data_write_memory_bytes): Likewise. (mi_cmd_trace_frame_collected): Likewise. * mi/mi-parse.c (mi_parse_argv): Likewise. (mi_parse): Likewise. * minidebug.c (lzma_open): Likewise. (lzma_pread): Likewise. * mips-tdep.c (mips_read_fp_register_single): Likewise. (mips_print_fp_register): Likewise. * mipsnbsd-tdep.c (mipsnbsd_get_longjmp_target): Likewise. * mipsread.c (read_alphacoff_dynamic_symtab): Likewise. * mt-tdep.c (mt_register_name): Likewise. (mt_registers_info): Likewise. (mt_push_dummy_call): Likewise. * namespace.c (add_using_directive): Likewise. * nat/linux-btrace.c (perf_event_read): Likewise. (linux_enable_bts): Likewise. * nat/linux-osdata.c (linux_common_core_of_thread): Likewise. * nat/linux-ptrace.c (linux_ptrace_test_ret_to_nx): Likewise. * nto-tdep.c (nto_find_and_open_solib): Likewise. (nto_parse_redirection): Likewise. * objc-lang.c (objc_demangle): Likewise. (find_methods): Likewise. * objfiles.c (get_objfile_bfd_data): Likewise. (set_objfile_main_name): Likewise. (allocate_objfile): Likewise. (objfile_relocate): Likewise. (update_section_map): Likewise. * osabi.c (generic_elf_osabi_sniff_abi_tag_sections): Likewise. * p-exp.y (exp): Likewise. (yylex): Likewise. * p-valprint.c (pascal_object_print_value): Likewise. * parse.c (initialize_expout): Likewise. (mark_completion_tag): Likewise. (copy_name): Likewise. (parse_float): Likewise. (type_stack_reserve): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. (ppu2spu_prev_register): Likewise. * ppc-ravenscar-thread.c (supply_register_at_address): Likewise. * printcmd.c (printf_wide_c_string): Likewise. (printf_pointer): Likewise. * probe.c (parse_probes): Likewise. * python/py-cmd.c (gdbpy_parse_command_name): Likewise. (cmdpy_init): Likewise. * python/py-gdb-readline.c (gdbpy_readline_wrapper): Likewise. * python/py-symtab.c (set_sal): Likewise. * python/py-unwind.c (pyuw_sniffer): Likewise. * python/python.c (python_interactive_command): Likewise. (compute_python_string): Likewise. * ravenscar-thread.c (get_running_thread_id): Likewise. * record-full.c (record_full_exec_insn): Likewise. (record_full_core_open_1): Likewise. * regcache.c (regcache_raw_read_signed): Likewise. (regcache_raw_read_unsigned): Likewise. (regcache_cooked_read_signed): Likewise. (regcache_cooked_read_unsigned): Likewise. * remote-fileio.c (remote_fileio_func_open): Likewise. (remote_fileio_func_rename): Likewise. (remote_fileio_func_unlink): Likewise. (remote_fileio_func_stat): Likewise. (remote_fileio_func_system): Likewise. * remote-mips.c (mips_xfer_memory): Likewise. (mips_load_srec): Likewise. (pmon_end_download): Likewise. * remote.c (new_remote_state): Likewise. (map_regcache_remote_table): Likewise. (remote_register_number_and_offset): Likewise. (init_remote_state): Likewise. (get_memory_packet_size): Likewise. (remote_pass_signals): Likewise. (remote_program_signals): Likewise. (remote_start_remote): Likewise. (remote_check_symbols): Likewise. (remote_query_supported): Likewise. (extended_remote_attach): Likewise. (process_g_packet): Likewise. (store_registers_using_G): Likewise. (putpkt_binary): Likewise. (read_frame): Likewise. (compare_sections_command): Likewise. (remote_hostio_pread): Likewise. (remote_hostio_readlink): Likewise. (remote_file_put): Likewise. (remote_file_get): Likewise. (remote_pid_to_exec_file): Likewise. (_initialize_remote): Likewise. * rs6000-aix-tdep.c (rs6000_aix_ld_info_to_xml): Likewise. (rs6000_aix_core_xfer_shared_libraries_aix): Likewise. * rs6000-tdep.c (ppc_displaced_step_copy_insn): Likewise. (bfd_uses_spe_extensions): Likewise. * s390-linux-tdep.c (s390_displaced_step_copy_insn): Likewise. * score-tdep.c (score7_malloc_and_get_memblock): Likewise. * solib-dsbt.c (decode_loadmap): Likewise. (fetch_loadmap): Likewise. (scan_dyntag): Likewise. (enable_break): Likewise. (dsbt_relocate_main_executable): Likewise. * solib-frv.c (fetch_loadmap): Likewise. (enable_break2): Likewise. (frv_relocate_main_executable): Likewise. * solib-spu.c (spu_relocate_main_executable): Likewise. (spu_bfd_open): Likewise. * solib-svr4.c (lm_info_read): Likewise. (read_program_header): Likewise. (find_program_interpreter): Likewise. (scan_dyntag): Likewise. (elf_locate_base): Likewise. (open_symbol_file_object): Likewise. (read_program_headers_from_bfd): Likewise. (svr4_relocate_main_executable): Likewise. * solib-target.c (solib_target_relocate_section_addresses): Likewise. * solib.c (solib_find_1): Likewise. (exec_file_find): Likewise. (solib_find): Likewise. * source.c (openp): Likewise. (print_source_lines_base): Likewise. (forward_search_command): Likewise. * sparc-ravenscar-thread.c (supply_register_at_address): Likewise. * spu-tdep.c (spu2ppu_prev_register): Likewise. (spu_get_overlay_table): Likewise. * stabsread.c (patch_block_stabs): Likewise. (define_symbol): Likewise. (again:): Likewise. (read_member_functions): Likewise. (read_one_struct_field): Likewise. (read_enum_type): Likewise. (common_block_start): Likewise. * stack.c (read_frame_arg): Likewise. (backtrace_command): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. * symfile.c (syms_from_objfile_1): Likewise. (find_separate_debug_file): Likewise. (load_command): Likewise. (load_progress): Likewise. (load_section_callback): Likewise. (reread_symbols): Likewise. (add_filename_language): Likewise. (allocate_compunit_symtab): Likewise. (read_target_long_array): Likewise. (simple_read_overlay_table): Likewise. * symtab.c (symbol_set_names): Likewise. (resize_symbol_cache): Likewise. (rbreak_command): Likewise. (completion_list_add_name): Likewise. (completion_list_objc_symbol): Likewise. (add_filename_to_list): Likewise. * target-descriptions.c (maint_print_c_tdesc_cmd): Likewise. * target-memory.c (target_write_memory_blocks): Likewise. * target.c (target_read_string): Likewise. (read_whatever_is_readable): Likewise. (target_read_alloc_1): Likewise. (simple_search_memory): Likewise. (target_fileio_read_alloc_1): Likewise. * tilegx-tdep.c (tilegx_push_dummy_call): Likewise. * top.c (command_line_input): Likewise. * tracefile-tfile.c (tfile_fetch_registers): Likewise. * tracefile.c (tracefile_fetch_registers): Likewise. * tracepoint.c (add_memrange): Likewise. (init_collection_list): Likewise. (add_aexpr): Likewise. (trace_dump_actions): Likewise. (parse_trace_status): Likewise. (parse_tracepoint_definition): Likewise. (parse_tsv_definition): Likewise. (parse_static_tracepoint_marker_definition): Likewise. * tui/tui-file.c (tui_sfileopen): Likewise. (tui_file_adjust_strbuf): Likewise. * tui/tui-io.c (tui_expand_tabs): Likewise. * tui/tui-source.c (tui_set_source_content): Likewise. * typeprint.c (find_global_typedef): Likewise. * ui-file.c (do_ui_file_xstrdup): Likewise. (ui_file_obsavestring): Likewise. (mem_file_write): Likewise. * utils.c (make_hex_string): Likewise. (get_regcomp_error): Likewise. (puts_filtered_tabular): Likewise. (gdb_realpath_keepfile): Likewise. (ldirname): Likewise. (gdb_bfd_errmsg): Likewise. (substitute_path_component): Likewise. * valops.c (search_struct_method): Likewise. (find_oload_champ_namespace_loop): Likewise. * valprint.c (print_decimal_chars): Likewise. (read_string): Likewise. (generic_emit_char): Likewise. * varobj.c (varobj_delete): Likewise. (varobj_value_get_print_value): Likewise. * vaxobsd-tdep.c (vaxobsd_sigtramp_sniffer): Likewise. * windows-tdep.c (display_one_tib): Likewise. * xcoffread.c (read_xcoff_symtab): Likewise. (process_xcoff_symbol): Likewise. (swap_sym): Likewise. (scan_xcoff_symtab): Likewise. (xcoff_initial_scan): Likewise. * xml-support.c (gdb_xml_end_element): Likewise. (xml_process_xincludes): Likewise. (xml_fetch_content_from_file): Likewise. * xml-syscall.c (xml_list_of_syscalls): Likewise. * xstormy16-tdep.c (xstormy16_push_dummy_call): Likewise. gdb/gdbserver/ChangeLog: * ax.c (gdb_parse_agent_expr): Add cast to allocation result assignment. (gdb_unparse_agent_expr): Likewise. * hostio.c (require_data): Likewise. (handle_pread): Likewise. * linux-low.c (disable_regset): Likewise. (fetch_register): Likewise. (store_register): Likewise. (get_dynamic): Likewise. (linux_qxfer_libraries_svr4): Likewise. * mem-break.c (delete_fast_tracepoint_jump): Likewise. (set_fast_tracepoint_jump): Likewise. (uninsert_fast_tracepoint_jumps_at): Likewise. (reinsert_fast_tracepoint_jumps_at): Likewise. (validate_inserted_breakpoint): Likewise. (clone_agent_expr): Likewise. * regcache.c (init_register_cache): Likewise. * remote-utils.c (putpkt_binary_1): Likewise. (decode_M_packet): Likewise. (decode_X_packet): Likewise. (look_up_one_symbol): Likewise. (relocate_instruction): Likewise. (monitor_output): Likewise. * server.c (handle_search_memory): Likewise. (handle_qxfer_exec_file): Likewise. (handle_qxfer_libraries): Likewise. (handle_qxfer): Likewise. (handle_query): Likewise. (handle_v_cont): Likewise. (handle_v_run): Likewise. (captured_main): Likewise. * target.c (write_inferior_memory): Likewise. * thread-db.c (try_thread_db_load_from_dir): Likewise. * tracepoint.c (init_trace_buffer): Likewise. (add_tracepoint_action): Likewise. (add_traceframe): Likewise. (add_traceframe_block): Likewise. (cmd_qtdpsrc): Likewise. (cmd_qtdv): Likewise. (cmd_qtstatus): Likewise. (response_source): Likewise. (response_tsv): Likewise. (cmd_qtnotes): Likewise. (gdb_collect): Likewise. (initialize_tracepoint): Likewise.
2015-09-25 20:08:06 +02:00
= (char *) obstack_alloc (&temp_parse_space, alloc_len);
* ada-lang.h (ada_renaming_category): New enumerated type. (ada_lookup_encoded_symbol): Declare. (ada_parse_renaming): Declare. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete declarations. * ada-lang.c (ada_parse_renaming): New function to concentrate extraction of information from renaming symbols. (parse_old_style_renaming): New function to concentrate extraction of old-style (purely type-based) renaming information. (renaming_is_visible): Rename to... (old_renaming_is_invisible): Rename and change sense of renaming_is_visible. (remove_out_of_scope_renamings): Rename to... (remove_irrelevant_renamings): Renames remove_out_of_scope_renamings and augments with additional logic to handle cases where the same object renaming is encoded both as a reference variable and an encoded renaming. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete definitions. (ada_lookup_encoded_symbol): New function factored out of ada_lookup_symbol. (ada_lookup_symbol): Reimplement to call ada_lookup_encoded_symbol. (wild_match): Don't reject perfect match of prefix. (ada_find_renaming_symbol): Factor old-style renaming logic into find_old_style_renaming_symbol. (find_old_style_renaming_symbol): New name for content of old ada_find_renaming_symbol. (ada_prefer_type): Reimplement not to use ada_renaming_type. * ada-exp.y (write_object_renaming): Change interface. Reimplement to use new arguments and ada_parse_renaming. Correct blocks used to find array index. (write_var_or_type): Reimplement to use ada_parse_renaming.
2007-12-21 12:50:11 +01:00
strncpy (new_name, renaming, renaming_len);
strcpy (new_name + renaming_len, encoded_name + tail_index);
encoded_name = new_name;
name_len = renaming_len + name_len - tail_index;
goto TryAfterRenaming;
}
case ADA_OBJECT_RENAMING:
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_object_renaming (par_state, block, renaming, renaming_len,
* ada-lang.h (ada_renaming_category): New enumerated type. (ada_lookup_encoded_symbol): Declare. (ada_parse_renaming): Declare. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete declarations. * ada-lang.c (ada_parse_renaming): New function to concentrate extraction of information from renaming symbols. (parse_old_style_renaming): New function to concentrate extraction of old-style (purely type-based) renaming information. (renaming_is_visible): Rename to... (old_renaming_is_invisible): Rename and change sense of renaming_is_visible. (remove_out_of_scope_renamings): Rename to... (remove_irrelevant_renamings): Renames remove_out_of_scope_renamings and augments with additional logic to handle cases where the same object renaming is encoded both as a reference variable and an encoded renaming. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete definitions. (ada_lookup_encoded_symbol): New function factored out of ada_lookup_symbol. (ada_lookup_symbol): Reimplement to call ada_lookup_encoded_symbol. (wild_match): Don't reject perfect match of prefix. (ada_find_renaming_symbol): Factor old-style renaming logic into find_old_style_renaming_symbol. (find_old_style_renaming_symbol): New name for content of old ada_find_renaming_symbol. (ada_prefer_type): Reimplement not to use ada_renaming_type. * ada-exp.y (write_object_renaming): Change interface. Reimplement to use new arguments and ada_parse_renaming. Correct blocks used to find array index. (write_var_or_type): Reimplement to use ada_parse_renaming.
2007-12-21 12:50:11 +01:00
renaming_expr, MAX_RENAMING_CHAIN_LENGTH);
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_selectors (par_state, encoded_name + tail_index);
* ada-lang.h (ada_renaming_category): New enumerated type. (ada_lookup_encoded_symbol): Declare. (ada_parse_renaming): Declare. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete declarations. * ada-lang.c (ada_parse_renaming): New function to concentrate extraction of information from renaming symbols. (parse_old_style_renaming): New function to concentrate extraction of old-style (purely type-based) renaming information. (renaming_is_visible): Rename to... (old_renaming_is_invisible): Rename and change sense of renaming_is_visible. (remove_out_of_scope_renamings): Rename to... (remove_irrelevant_renamings): Renames remove_out_of_scope_renamings and augments with additional logic to handle cases where the same object renaming is encoded both as a reference variable and an encoded renaming. (ada_renaming_type,ada_is_object_renaming) (ada_simple_renamed_entity): Delete definitions. (ada_lookup_encoded_symbol): New function factored out of ada_lookup_symbol. (ada_lookup_symbol): Reimplement to call ada_lookup_encoded_symbol. (wild_match): Don't reject perfect match of prefix. (ada_find_renaming_symbol): Factor old-style renaming logic into find_old_style_renaming_symbol. (find_old_style_renaming_symbol): New name for content of old ada_find_renaming_symbol. (ada_prefer_type): Reimplement not to use ada_renaming_type. * ada-exp.y (write_object_renaming): Change interface. Reimplement to use new arguments and ada_parse_renaming. Correct blocks used to find array index. (write_var_or_type): Reimplement to use ada_parse_renaming.
2007-12-21 12:50:11 +01:00
return NULL;
default:
internal_error (__FILE__, __LINE__,
_("impossible value from ada_parse_renaming"));
}
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
if (type_sym != NULL)
{
struct type *field_type;
if (tail_index == name_len)
return SYMBOL_TYPE (type_sym);
/* We have some extraneous characters after the type name.
If this is an expression "TYPE_NAME.FIELD0.[...].FIELDN",
then try to get the type of FIELDN. */
field_type
= get_symbol_field_type (type_sym, encoded_name + tail_index);
if (field_type != NULL)
return field_type;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
else
error (_("Invalid attempt to select from type: \"%s\"."),
name0.ptr);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
}
else if (tail_index == name_len && nsyms == 0)
{
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
struct type *type = find_primitive_type (par_state,
encoded_name);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
if (type != NULL)
return type;
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
}
if (nsyms == 1)
{
local variable watchpoint not deleted after leaving scope When debugging an Ada program, and inserting a watchpoint tracking a local variable, the watchpoint doesn't get automatically deleted upon leaving that variable's scope. This watchpoint then starts creating problems later on, when trying to resume the program's execution from a location outside of the watchpoint's scope: (gdb) c Continuing. Breakpoint 2, foo_p708_025 () at foo_p708_025.adb:7 7 Do_Nothing (Val); (gdb) n No frame is currently executing in block pck.get_val. Command aborted. (gdb) c Continuing. No frame is currently executing in block pck.get_val. Command aborted. The expected output is the following: - The program's execution after the first continue should stop as soon as we reach the end of the watchpoint's scope, and the debugger should be deleting it. - Then we can continue until reaching breakpoint 2 above; - After which we should be able to do next/continue as usual. The reason the watchpoint is not automatically deleted at scope exit is because the watchpoint is not marked as being scope-specific (b->exp_valid_block is equal NULL), and this is because the symbol lookup for our local variable failed to set the innermost_block global variable during the lookup. More precisely, if we look at watch_command_1, we do the following: innermost_block = NULL; [...] exp = parse_exp_1 (&arg, 0, 0, 0); [...] exp_valid_block = innermost_block; Currently, innermost_block stays NULL after the call to parse_exp_1. Digging further, this innermost_block is typically set during symbol lookup when the symbol is considered to have a frame-relative address. For instance, in c-exp.y, we see some code like the following: if (symbol_read_needs_frame (sym.symbol)) { if (innermost_block == 0 || contained_in (sym.block, innermost_block)) innermost_block = sym.block; } We actually have the exact same mechanism in ada-exp.y, except that it vhas accidently been turned off. See write_var_from_sym, where we start with: if (orig_left_context == NULL && symbol_read_needs_frame (sym)) { if (innermost_block == 0 || contained_in (block, innermost_block)) innermost_block = block; } In this case, orig_left_context is a parameter, and looking at the point of call in write_var_or_type, we see: if (nsyms == 1) { write_var_from_sym (par_state, block, syms[0].block, syms[0].symbol); In the call above, the paramater we are interested in is "block", which is a parameter for write_var_or_type as well, except we explicitly override its value at the beginning when found to be NULL: if (block == NULL) block = expression_context_block; So the block we pass to write_var_from_sym is not NULL, and we therefore don't set innermost_block, which leads to the watchpoint no longer being marked as scope-specific. The handling of orig_left_context in write_var_from_sym was there to handle the case where a user writes an expression where the symbol is qualified with a scope (Eg: "function::variable"). But it appears that handling this is specifically here is no longer necessary, so this patch simply removes that parameter and the associated check, and then updates all the points of calls. Interestingly, this also affects GDB/MI, and in particular varobjs, because local variables are now properly reported as having a block, which causes the associated varob to have a "thread-id" field. This patch also adjusts a couple of Ada/gdb-mi tests. gdb/ChangeLog: * ada-exp.y (write_var_from_sym): Remove parameter "orig_left_context". Update all callers. gdb/testsuite/ChangeLog: * gdb.ada/scoped_watch: New testcase. * gdb.ada/watch_arg.exp: Adjust expected behavior to the behavior which is actually correct. * gdb.ada/mi_interface.exp: Add missing thread-id in expected varobj. * gdb.ada/mi_var_array.exp: Add missing thread-id in expected varobj.
2017-03-03 17:31:13 +01:00
write_var_from_sym (par_state, syms[0].block, syms[0].symbol);
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_selectors (par_state, encoded_name + tail_index);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
return NULL;
}
else if (nsyms == 0)
{
remove msymbol_objfile This is another patch in my ongoing series to "split" objfile to share more read-only data across inferiors. See http://sourceware.org/gdb/wiki/ObjfileSplitting When symbols are finally shared, there will be no back-link from the symbol to its containing objfile, because there may be more than one such objfile. So, all such back-links must be removed. One hidden back-link is the msymbol_objfile function. Since (eventually) a symbol may appear in more than one objfile, trying to look up the objfile given just a symbol cannot work. This patch removes msymbol_objfile in favor of using a bound minimal symbol. It introduces a new function to make this conversion simpler in some spots. The bonus of this patch is that using msymbol_objfile is slower than simply looking up the owning objfile in the first place. Built and regtested on x86-64 Fedora 18. * ada-exp.y (write_var_or_type): Use bound_minimal_symbol. * ada-lang.c (ada_lookup_simple_minsym): Return bound_minimal_symbol. * ada-lang.h (ada_lookup_simple_minsym): Update. * c-exp.y (variable): Use lookup_bound_minimal_symbol. * f-exp.y (variable): Use lookup_bound_minimal_symbol. * go-exp.y (variable): Use lookup_bound_minimal_symbol. * jv-exp.y (push_expression_name): Use lookup_bound_minimal_symbol. * m2-exp.y (variable): Use lookup_bound_minimal_symbol. * minsyms.c (msymbol_objfile): Remove. (lookup_minimal_symbol_internal): New function, from lookup_minimal_symbol. (lookup_minimal_symbol): Rewrite using lookup_minimal_symbol_internal. (lookup_bound_minimal_symbol): New function. * minsyms.h (msymbol_objfile): Remove. (lookup_bound_minimal_symbol): Declare. * p-exp.y (variable): Use lookup_bound_minimal_symbol. * parse.c (write_exp_msymbol): Change parameter to a bound_minimal_symbol. (write_dollar_variable): Use lookup_bound_minimal_symbol. * parser-defs.h (write_exp_msymbol): Update. * printcmd.c (address_info): Use lookup_bound_minimal_symbol. * symfile.c (simple_read_overlay_table): Use lookup_bound_minimal_symbol. * symtab.c (skip_prologue_sal): Don't use msymbol_objfile. (search_symbols): Likewise. (print_msymbol_info): Take a bound_minimal_symbol argument. (symtab_symbol_info, rbreak_command): Update. * symtab.h (struct symbol_search) <msymbol>: Change type to bound_minimal_symbol. * valops.c (find_function_in_inferior): Use lookup_bound_minimal_symbol. * value.c (value_fn_field): Use lookup_bound_minimal_symbol.
2013-08-05 17:51:02 +02:00
struct bound_minimal_symbol msym
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
= ada_lookup_simple_minsym (encoded_name);
remove msymbol_objfile This is another patch in my ongoing series to "split" objfile to share more read-only data across inferiors. See http://sourceware.org/gdb/wiki/ObjfileSplitting When symbols are finally shared, there will be no back-link from the symbol to its containing objfile, because there may be more than one such objfile. So, all such back-links must be removed. One hidden back-link is the msymbol_objfile function. Since (eventually) a symbol may appear in more than one objfile, trying to look up the objfile given just a symbol cannot work. This patch removes msymbol_objfile in favor of using a bound minimal symbol. It introduces a new function to make this conversion simpler in some spots. The bonus of this patch is that using msymbol_objfile is slower than simply looking up the owning objfile in the first place. Built and regtested on x86-64 Fedora 18. * ada-exp.y (write_var_or_type): Use bound_minimal_symbol. * ada-lang.c (ada_lookup_simple_minsym): Return bound_minimal_symbol. * ada-lang.h (ada_lookup_simple_minsym): Update. * c-exp.y (variable): Use lookup_bound_minimal_symbol. * f-exp.y (variable): Use lookup_bound_minimal_symbol. * go-exp.y (variable): Use lookup_bound_minimal_symbol. * jv-exp.y (push_expression_name): Use lookup_bound_minimal_symbol. * m2-exp.y (variable): Use lookup_bound_minimal_symbol. * minsyms.c (msymbol_objfile): Remove. (lookup_minimal_symbol_internal): New function, from lookup_minimal_symbol. (lookup_minimal_symbol): Rewrite using lookup_minimal_symbol_internal. (lookup_bound_minimal_symbol): New function. * minsyms.h (msymbol_objfile): Remove. (lookup_bound_minimal_symbol): Declare. * p-exp.y (variable): Use lookup_bound_minimal_symbol. * parse.c (write_exp_msymbol): Change parameter to a bound_minimal_symbol. (write_dollar_variable): Use lookup_bound_minimal_symbol. * parser-defs.h (write_exp_msymbol): Update. * printcmd.c (address_info): Use lookup_bound_minimal_symbol. * symfile.c (simple_read_overlay_table): Use lookup_bound_minimal_symbol. * symtab.c (skip_prologue_sal): Don't use msymbol_objfile. (search_symbols): Likewise. (print_msymbol_info): Take a bound_minimal_symbol argument. (symtab_symbol_info, rbreak_command): Update. * symtab.h (struct symbol_search) <msymbol>: Change type to bound_minimal_symbol. * valops.c (find_function_in_inferior): Use lookup_bound_minimal_symbol. * value.c (value_fn_field): Use lookup_bound_minimal_symbol.
2013-08-05 17:51:02 +02:00
if (msym.minsym != NULL)
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
{
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_exp_msymbol (par_state, msym);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
/* Maybe cause error here rather than later? FIXME? */
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_selectors (par_state, encoded_name + tail_index);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
return NULL;
}
if (tail_index == name_len
&& strncmp (encoded_name, "standard__",
sizeof ("standard__") - 1) == 0)
error (_("No definition of \"%s\" found."), name0.ptr);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
tail_index = chop_selector (encoded_name, tail_index);
}
else
{
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_ambiguous_var (par_state, block, encoded_name,
tail_index);
write_selectors (par_state, encoded_name + tail_index);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
return NULL;
}
}
if (!have_full_symbols () && !have_partial_symbols () && block == NULL)
error (_("No symbol table is loaded. Use the \"file\" command."));
if (block == par_state->expression_context_block)
error (_("No definition of \"%s\" in current context."), name0.ptr);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
else
error (_("No definition of \"%s\" in specified context."), name0.ptr);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
TryAfterRenaming: ;
}
error (_("Could not find renamed symbol \"%s\""), name0.ptr);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
}
/* Write a left side of a component association (e.g., NAME in NAME =>
exp). If NAME has the form of a selected component, write it as an
ordinary expression. If it is a simple variable that unambiguously
corresponds to exactly one symbol that does not denote a type or an
object renaming, also write it normally as an OP_VAR_VALUE.
Otherwise, write it as an OP_NAME.
Unfortunately, we don't know at this point whether NAME is supposed
to denote a record component name or the value of an array index.
Therefore, it is not appropriate to disambiguate an ambiguous name
as we normally would, nor to replace a renaming with its referent.
As a result, in the (one hopes) rare case that one writes an
aggregate such as (R => 42) where R renames an object or is an
ambiguous name, one must write instead ((R) => 42). */
static void
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_name_assoc (struct parser_state *par_state, struct stoken name)
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
{
if (strchr (name.ptr, '.') == NULL)
{
std::vector<struct block_symbol> syms;
int nsyms = ada_lookup_symbol_list (name.ptr,
par_state->expression_context_block,
VAR_DOMAIN, &syms);
Replace the block_found global with explicit data-flow As Pedro suggested on gdb-patches@ (see https://sourceware.org/ml/gdb-patches/2015-05/msg00714.html), this change makes symbol lookup functions return a structure that includes both the symbol found and the block in which it was found. This makes it possible to get rid of the block_found global variable and thus makes block hunting explicit. gdb/ * ada-exp.y (write_object_renaming): Replace struct ada_symbol_info with struct block_symbol. Update field references accordingly. (block_lookup, select_possible_type_sym): Likewise. (find_primitive_type): Likewise. Also update call to ada_lookup_symbol to extract the symbol itself. (write_var_or_type, write_name_assoc): Likewise. * ada-lang.h (struct ada_symbol_info): Remove. (ada_lookup_symbol_list): Replace struct ada_symbol_info with struct block_symbol. (ada_lookup_encoded_symbol, user_select_syms): Likewise. (ada_lookup_symbol): Return struct block_symbol instead of a mere symbol. * ada-lang.c (defns_collected): Replace struct ada_symbol_info with struct block_symbol. (resolve_subexp, ada_resolve_function, sort_choices, user_select_syms, is_nonfunction, add_defn_to_vec, num_defns_collected, defns_collected, symbols_are_identical_enums, remove_extra_symbols, remove_irrelevant_renamings, add_lookup_symbol_list_worker, ada_lookup_symbol_list, ada_iterate_over_symbols, ada_lookup_encoded_symbol, get_var_value): Likewise. (ada_lookup_symbol): Return a block_symbol instead of a mere symbol. Replace struct ada_symbol_info with struct block_symbol. (ada_lookup_symbol_nonlocal): Likewise. (standard_lookup): Make block passing explicit through lookup_symbol_in_language. * ada-tasks.c (get_tcb_types_info): Update the calls to lookup_symbol_in_language to extract the mere symbol out of the returned value. (ada_tasks_inferior_data_sniffer): Likewise. * ax-gdb.c (gen_static_field): Likewise for the call to lookup_symbol. (gen_maybe_namespace_elt): Deal with struct symbol_in_block from lookup functions. (gen_expr): Likewise. * c-exp.y: Likewise. Remove uses of block_found. (lex_one_token, classify_inner_name, c_print_token): Likewise. (classify_name): Likewise. Rename the "sym" local variable to "bsym". * c-valprint.c (print_unpacked_pointer): Likewise. * compile/compile-c-symbols.c (convert_symbol_sym): Promote the "sym" parameter from struct symbol * to struct block_symbol. Use it to remove uses of block_found. Deal with struct symbol_in_block from lookup functions. (gcc_convert_symbol): Likewise. Update the call to convert_symbol_sym. * compile/compile-object-load.c (compile_object_load): Deal with struct symbol_in_block from lookup functions. * cp-namespace.c (cp_lookup_nested_symbol_1, cp_lookup_nested_symbol, cp_lookup_bare_symbol, cp_search_static_and_baseclasses, cp_lookup_symbol_in_namespace, cp_lookup_symbol_via_imports, cp_lookup_symbol_imports_or_template, cp_lookup_symbol_via_all_imports, cp_lookup_symbol_namespace, lookup_namespace_scope, cp_lookup_nonlocal, find_symbol_in_baseclass): Return struct symbol_in_block instead of mere symbols and deal with struct symbol_in_block from lookup functions. * cp-support.c (inspect_type, replace_typedefs, cp_lookup_rtti_type): Deal with struct symbol_in_block from lookup functions. * cp-support.h (cp_lookup_symbol_nonlocal, cp_lookup_symbol_from_namespace, cp_lookup_symbol_imports_or_template, cp_lookup_nested_symbol): Return struct symbol_in_block instead of mere symbols. * d-exp.y (d_type_from_name, d_module_from_name, push_variable, push_module_name): Deal with struct symbol_in_block from lookup functions. Remove uses of block_found. * eval.c (evaluate_subexp_standard): Update call to cp_lookup_symbol_namespace. * f-exp.y: Deal with struct symbol_in_block from lookup functions. Remove uses of block_found. (yylex): Likewise. * gdbtypes.c (lookup_typename, lookup_struct, lookup_union, lookup_enum, lookup_template_type, check_typedef): Deal with struct symbol_in_block from lookup functions. * guile/scm-frame.c (gdbscm_frame_read_var): Likewise. * guile/scm-symbol.c (gdbscm_lookup_symbol): Likewise. (gdbscm_lookup_global_symbol): Likewise. * gnu-v3-abi.c (gnuv3_get_typeid_type): Likewise. * go-exp.y: Likewise. Remove uses of block_found. (package_name_p, classify_packaged_name, classify_name): Likewise. * infrun.c (insert_exception_resume_breakpoint): Likewise. * jv-exp.y (push_variable): Likewise. * jv-lang.c (java_lookup_class, get_java_object_type): Likewise. * language.c (language_bool_type): Likewise. * language.h (struct language_defn): Update la_lookup_symbol_nonlocal to return a struct symbol_in_block rather than a mere symbol. * linespec.c (find_label_symbols): Deal with struct symbol_in_block from lookup functions. * m2-exp.y: Likewise. Remove uses of block_found. (yylex): Likewise. * mi/mi-cmd-stack.c (list_args_or_locals): Likewise. * objc-lang.c (lookup_struct_typedef, find_imps): Likewise. * p-exp.y: Likewise. Remove uses of block_found. (yylex): Likewise. * p-valprint.c (pascal_val_print): Likewise. * parse.c (write_dollar_variable): Likewise. Remove uses of block_found. * parser-defs.h (struct symtoken): Turn the SYM field into a struct symbol_in_block. * printcmd.c (address_info): Deal with struct symbol_in_block from lookup functions. * python/py-frame.c (frapy_read_var): Likewise. * python/py-symbol.c (gdbpy_lookup_symbol, gdbpy_lookup_global_symbol): Likewise. * skip.c (skip_function_command): Likewise. * solib-darwin.c (darwin_lookup_lib_symbol): Return a struct symbol_in_block instead of a mere symbol. * solib-spu.c (spu_lookup_lib_symbol): Likewise. * solib-svr4.c (elf_lookup_lib_symbol): Likewise. * solib.c (solib_global_lookup): Likewise. * solist.h (solib_global_lookup): Likewise. (struct target_so_ops): Update lookup_lib_global_symbol to return a struct symbol_in_block rather than a mere symbol. * source.c (select_source_symtab): Deal with struct symbol_in_block from lookup functions. * stack.c (print_frame_args, iterate_over_block_arg_vars): Likewise. * symfile.c (set_initial_language): Likewise. * symtab.c (SYMBOL_LOOKUP_FAILED): Turn into a struct symbol_in_block. (SYMBOL_LOOKUP_FAILED_P): New predicate as a macro. (struct symbol_cache_slot): Turn the FOUND field into a struct symbol_in_block. (block_found): Remove. (eq_symbol_entry): Update to deal with struct symbol_in_block in cache slots. (symbol_cache_lookup): Return a struct symbol_in_block rather than a mere symbol. (symbol_cache_mark_found): Add a BLOCK parameter to fill appropriately the cache slots. Update callers. (symbol_cache_dump): Update cache slots handling to the type change. (lookup_symbol_in_language, lookup_symbol, lookup_language_this, lookup_symbol_aux, lookup_local_symbol, lookup_symbol_in_objfile, lookup_global_symbol_from_objfile, lookup_symbol_in_objfile_symtabs, lookup_symbol_in_objfile_from_linkage_name, lookup_symbol_via_quick_fns, basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block, lookup_static_symbol, lookup_global_symbol): Return a struct symbol_in_block rather than a mere symbol. Deal with struct symbol_in_block from other lookup functions. Remove uses of block_found. (lookup_symbol_in_block): Remove uses of block_found. (struct global_sym_lookup_data): Turn the RESULT field into a struct symbol_in_block. (lookup_symbol_global_iterator_cb): Update references to the RESULT field. (search_symbols): Deal with struct symbol_in_block from lookup functions. * symtab.h (struct symbol_in_block): New structure. (block_found): Remove. (lookup_symbol_in_language, lookup_symbol, basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block, looku_static_symbol, lookup_global_symbol, lookup_symbol_in_block, lookup_language_this, lookup_global_symbol_from_objfile): Return a struct symbol_in_block rather than just a mere symbol. Update comments to remove mentions of block_found. * valops.c (find_function_in_inferior, value_struct_elt_for_reference, value_maybe_namespace_elt, value_of_this): Deal with struct symbol_in_block from lookup functions. * value.c (value_static_field, value_fn_field): Likewise.
2015-07-21 17:02:15 +02:00
if (nsyms != 1 || SYMBOL_CLASS (syms[0].symbol) == LOC_TYPEDEF)
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
write_exp_op_with_string (par_state, OP_NAME, name);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
else
local variable watchpoint not deleted after leaving scope When debugging an Ada program, and inserting a watchpoint tracking a local variable, the watchpoint doesn't get automatically deleted upon leaving that variable's scope. This watchpoint then starts creating problems later on, when trying to resume the program's execution from a location outside of the watchpoint's scope: (gdb) c Continuing. Breakpoint 2, foo_p708_025 () at foo_p708_025.adb:7 7 Do_Nothing (Val); (gdb) n No frame is currently executing in block pck.get_val. Command aborted. (gdb) c Continuing. No frame is currently executing in block pck.get_val. Command aborted. The expected output is the following: - The program's execution after the first continue should stop as soon as we reach the end of the watchpoint's scope, and the debugger should be deleting it. - Then we can continue until reaching breakpoint 2 above; - After which we should be able to do next/continue as usual. The reason the watchpoint is not automatically deleted at scope exit is because the watchpoint is not marked as being scope-specific (b->exp_valid_block is equal NULL), and this is because the symbol lookup for our local variable failed to set the innermost_block global variable during the lookup. More precisely, if we look at watch_command_1, we do the following: innermost_block = NULL; [...] exp = parse_exp_1 (&arg, 0, 0, 0); [...] exp_valid_block = innermost_block; Currently, innermost_block stays NULL after the call to parse_exp_1. Digging further, this innermost_block is typically set during symbol lookup when the symbol is considered to have a frame-relative address. For instance, in c-exp.y, we see some code like the following: if (symbol_read_needs_frame (sym.symbol)) { if (innermost_block == 0 || contained_in (sym.block, innermost_block)) innermost_block = sym.block; } We actually have the exact same mechanism in ada-exp.y, except that it vhas accidently been turned off. See write_var_from_sym, where we start with: if (orig_left_context == NULL && symbol_read_needs_frame (sym)) { if (innermost_block == 0 || contained_in (block, innermost_block)) innermost_block = block; } In this case, orig_left_context is a parameter, and looking at the point of call in write_var_or_type, we see: if (nsyms == 1) { write_var_from_sym (par_state, block, syms[0].block, syms[0].symbol); In the call above, the paramater we are interested in is "block", which is a parameter for write_var_or_type as well, except we explicitly override its value at the beginning when found to be NULL: if (block == NULL) block = expression_context_block; So the block we pass to write_var_from_sym is not NULL, and we therefore don't set innermost_block, which leads to the watchpoint no longer being marked as scope-specific. The handling of orig_left_context in write_var_from_sym was there to handle the case where a user writes an expression where the symbol is qualified with a scope (Eg: "function::variable"). But it appears that handling this is specifically here is no longer necessary, so this patch simply removes that parameter and the associated check, and then updates all the points of calls. Interestingly, this also affects GDB/MI, and in particular varobjs, because local variables are now properly reported as having a block, which causes the associated varob to have a "thread-id" field. This patch also adjusts a couple of Ada/gdb-mi tests. gdb/ChangeLog: * ada-exp.y (write_var_from_sym): Remove parameter "orig_left_context". Update all callers. gdb/testsuite/ChangeLog: * gdb.ada/scoped_watch: New testcase. * gdb.ada/watch_arg.exp: Adjust expected behavior to the behavior which is actually correct. * gdb.ada/mi_interface.exp: Add missing thread-id in expected varobj. * gdb.ada/mi_var_array.exp: Add missing thread-id in expected varobj.
2017-03-03 17:31:13 +01:00
write_var_from_sym (par_state, syms[0].block, syms[0].symbol);
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
}
else
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
if (write_var_or_type (par_state, NULL, name) != NULL)
error (_("Invalid use of type."));
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
}
2002-06-04 17:28:49 +02:00
/* Convert the character literal whose ASCII value would be VAL to the
appropriate value of type TYPE, if there is a translation.
Otherwise return VAL. Hence, in an enumeration type ('A', 'B'),
the literal 'A' (VAL == 65), returns 0. */
* ada-exp.y: Considerable reorganization to move functionality from ada-lex.l to here, where it is logically more appropriate. The original reason, however, was to prevent premature name lookups for selector names in record aggregates. (BLOCKNAME, TYPENAME, OBJECT_RENAMING): Remove; lexer now returns NAME for all of these. (VAR): New artificial token to clarify precedence rules. (OTHERS): New lexeme. (empty_stoken): New symbol. (%union): Remove ssym, voidval. (%type): Remove <voidval> type declarations. (syntax definitions): Add aggregates. Remove distinction between NAME, TYPENAME, BLOCKNAME, OBJECT_RENAMING. Rename some non-terminals to be closer to reference manual usage. Tighten up expression syntax to disallow certain non-Ada constructions such as X and then Y or else Z. (ada_parse): Remove initialization of left_block_context. (write_var_from_name): Remove. (write_var_or_type): New function, containing previous code from defunct write_var_from_name and name_lookup. (block_lookup): New function, moved from ada-lex.l (select_possible_type_sym): New function, factored out of name_lookup, which used to be in ada-lex.l. (find_primitive_type): Ditto. (chop_selector): Ditto. (write_ambiguous_var): New function, factored out of defunct write_var_from_name. (write_selectors): New function. (write_name_assoc): New function. (write_exp_op_with_string): New function. * ada-lex.l (processId): Change interface to return stoken. (tempbuf, resize_tempbuf, tempbuf_size, tempbuf_len): Remove. (block_lookup, name_lookup): Remove. Functionality moved to ada-exp.y. (state IN_STRING): Remove. (rules): Handle string escapes in processString. Add 'others' token. Return all NAMEs, BLOCKNAMEs, OBJECT_RENAMINGs, TYPENAMEs in yylval.sval (as simple strings). All name look-ups now handled in ada-exp.y. Introduce "::" (COLONCOLON) token and return as separate token. (processId): Change return convention. Comment. Leave leading "'" in place. (processString): New function. (find_dot_all): Add note to comment. Fix problem that allowed match only at the end. * ada-lang.c: Introduce aggregates. (find_struct_field): Add new parameter to count fields skipped, and allow other output parameters to be NULL. (value_tag_from_contents_and_address, ada_value_struct_elt): Use new find_struct_field. (ada_index_struct_field, assign_aggregate, ada_is_array_type) (num_visible_fields, ada_index_struct_field_1, ada_index_struct_field) (num_component_specs, assign_component, assign_aggregate): (aggregate_assign_from_choices,aggregate_assign_positional) (aggregate_assign_others,add_component_interval): New functions. (ada_evaluate_subexp): Declare. Add aggregate-related operators. (ada_forward_operator_length): Declare. (resolve_subexp): Add cases for new aggregate operators and OP_NAME. Consolidate Ada operators, using ada_forward_operator_length. (ada_search_struct_field): Search in forward order. (ADA_OPERATORS): Add new aggregate operators. (ada_operator_length, ada_op_name, ada_forward_operator_length) (ada_dump_subexp_body, ada_print_subexp): Handle new aggregate operators and OP_NAME. (ada_type_of_array): Use longest_to_int. (value_assign_to_component): New function. (ada_forward_operator_length, ada_op_name, ada_dump_subexp_body): Add OP_NAME case. (ada_forward_operator_length, ada_dump_subexp_body): Add OP_STRING case. * ada-lang.h (enum ada_operator): Add OP_AGGREGATE, OP_OTHERS, OP_CHOICES, OP_DISCRETE_RANGE, OP_POSITIONAL.
2006-01-02 10:46:34 +01:00
2002-06-04 17:28:49 +02:00
static LONGEST
convert_char_literal (struct type *type, LONGEST val)
2002-06-04 17:28:49 +02:00
{
char name[7];
int f;
if (type == NULL)
2002-06-04 17:28:49 +02:00
return val;
type = check_typedef (type);
if (type->code () != TYPE_CODE_ENUM)
return val;
if ((val >= 'a' && val <= 'z') || (val >= '0' && val <= '9'))
xsnprintf (name, sizeof (name), "Q%c", (int) val);
else
xsnprintf (name, sizeof (name), "QU%02x", (int) val);
size_t len = strlen (name);
for (f = 0; f < TYPE_NFIELDS (type); f += 1)
2002-06-04 17:28:49 +02:00
{
/* Check the suffix because an enum constant in a package will
have a name like "pkg__QUxx". This is safe enough because we
already have the correct type, and because mangling means
there can't be clashes. */
const char *ename = TYPE_FIELD_NAME (type, f);
size_t elen = strlen (ename);
if (elen >= len && strcmp (name, ename + elen - len) == 0)
gdb/ PR symtab/7259: * ada-exp.y (convert_char_literal): Use TYPE_FIELD_ENUMVAL. * ada-lang.c (ada_discrete_type_high_bound) (ada_discrete_type_low_bound): Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM. (ada_identical_enum_types_p): Use TYPE_FIELD_ENUMVAL. (pos_atr, value_val_atr): Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM. * ada-typeprint.c (print_enum_type): Change variable lastval to LONGEST. Use TYPE_FIELD_ENUMVAL. * ada-valprint.c (print_optional_low_bound, ada_print_scalar) (ada_val_print_1): Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM. * c-typeprint.c (c_type_print_base): Move variable lastval to inner block, change it to LONGEST. Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM. * coffread.c (coff_read_enum_type): Use SET_FIELD_ENUMVAL. * dwarf2read.c (process_enumeration_scope): Likewise. * gdb-gdb.py (TypeFlagsPrinter): Use field.enumval instead of field.bitpos. (class StructMainTypePrettyPrinter): Support also FIELD_LOC_KIND_ENUMVAL. * gdbtypes.c (get_discrete_bounds): Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM. (recursive_dump_type): Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM. (copy_type_recursive): Support also FIELD_LOC_KIND_ENUMVAL. * gdbtypes.h (enum field_loc_kind): New FIELD_LOC_KIND_ENUMVAL. (struct main_type.flds_bnds.fields.loc): Adjust bitpos comment. New field enumval. (struct main_type.flds_bnds.bields): Adjust loc_kind and bitsize to accommodate enumval. (struct call_site): Adjust loc_kind to accommodate enumval. (FIELD_ENUMVAL, FIELD_ENUMVAL_LVAL, SET_FIELD_ENUMVAL) (TYPE_FIELD_ENUMVAL): New macros. * m2-typeprint.c (m2_enum): Use TYPE_FIELD_ENUMVAL. * mdebugread.c (parse_symbol): Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM. * p-typeprint.c (pascal_type_print_base): Likewise. * python/lib/gdb/printing.py (class FlagEnumerationPrinter): Use enumval. * python/lib/gdb/types.py (make_enum_dict): Likewise. * python/py-type.c (convert_field): New variable addrstring. Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM. (check_types_equal): Support also FIELD_LOC_KIND_ENUMVAL. * stabsread.c (read_enum_type): Use SET_FIELD_ENUMVAL. * typepint.c (print_type_scalar): Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM. * valprint.c (generic_val_print): Likewise. gdb/testsuite/ PR symtab/7259: * gdb.base/enumval.c: New test case. * gdb.base/enumval.exp: New test case. * gdb.python/py-type.exp (test_enums): Use field.enumval instead of field.bitpos.
2012-04-18 08:46:47 +02:00
return TYPE_FIELD_ENUMVAL (type, f);
2002-06-04 17:28:49 +02:00
}
return val;
}
* ada-exp.y (type_int): New function to add layer of abstraction around references to expression types. (type_long): Ditto. (type_long_long): Ditto. (type_float): Ditto. (type_double): Ditto. (type_long_double): Ditto. (type_char): Ditto. (type_system_address): Ditto. (simple_exp): Use type_* functions in place of builtin_* variables. (exp): Ditto. (write_var_from_name): Ditto. (write_object_renaming): Ditto. * ada-lang.c (ada_create_fundamental_type): Remove redundant declaration. (build_ada_types): Remove, replacing with... (ada_language_arch_info): New function to initialize primitive type vector in language_arch_info. (ada_array_length): Remove use of builtin_type_ada_int. (value_pos_atr): Ditto. (ada_evaluate_subexp): Ditto. (builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long, builtin_type_ada_long_long, builtin_type_ada_char, builtin_type_ada_float, builtin_type_ada_double, builtin_type_ada_long_double, builtin_type_ada_natural, builtin_type_ada_positive, builtin_type_ada_system_address): Remove. (ada_builtin_types): Remove. (ada_language_defn): Remove entries for la_builtin_type_vector and string_char_type and use ada_language_arch_info. (_initialize_ada_language): Do type-vector initialization along the lines of c-lang.c. (ada_create_fundamental_type): Break up line. (ada_dump_symtab): Remove unused function. (enum ada_primitive_types): Define. * ada-lang.h (builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long,builtin_type_ada_long_long,builtin_type_ada_char, builtin_type_ada_float, builtin_type_ada_double, builtin_type_ada_long_double, builtin_type_ada_natural, builtin_type_ada_positive, builtin_type_ada_system_address): Remove. * ada-lex.l: Use type_* functions in place of builtin_* variables. (processInt): Ditto. (processReal): Ditto. (name_lookup): Ditto. * ada-typeprint.c (print_range): Use builtin_type_int, not builtin_type_ada_int.
2004-09-19 00:23:23 +02:00
static struct type *
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
type_int (struct parser_state *par_state)
* ada-exp.y (type_int): New function to add layer of abstraction around references to expression types. (type_long): Ditto. (type_long_long): Ditto. (type_float): Ditto. (type_double): Ditto. (type_long_double): Ditto. (type_char): Ditto. (type_system_address): Ditto. (simple_exp): Use type_* functions in place of builtin_* variables. (exp): Ditto. (write_var_from_name): Ditto. (write_object_renaming): Ditto. * ada-lang.c (ada_create_fundamental_type): Remove redundant declaration. (build_ada_types): Remove, replacing with... (ada_language_arch_info): New function to initialize primitive type vector in language_arch_info. (ada_array_length): Remove use of builtin_type_ada_int. (value_pos_atr): Ditto. (ada_evaluate_subexp): Ditto. (builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long, builtin_type_ada_long_long, builtin_type_ada_char, builtin_type_ada_float, builtin_type_ada_double, builtin_type_ada_long_double, builtin_type_ada_natural, builtin_type_ada_positive, builtin_type_ada_system_address): Remove. (ada_builtin_types): Remove. (ada_language_defn): Remove entries for la_builtin_type_vector and string_char_type and use ada_language_arch_info. (_initialize_ada_language): Do type-vector initialization along the lines of c-lang.c. (ada_create_fundamental_type): Break up line. (ada_dump_symtab): Remove unused function. (enum ada_primitive_types): Define. * ada-lang.h (builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long,builtin_type_ada_long_long,builtin_type_ada_char, builtin_type_ada_float, builtin_type_ada_double, builtin_type_ada_long_double, builtin_type_ada_natural, builtin_type_ada_positive, builtin_type_ada_system_address): Remove. * ada-lex.l: Use type_* functions in place of builtin_* variables. (processInt): Ditto. (processReal): Ditto. (name_lookup): Ditto. * ada-typeprint.c (print_range): Use builtin_type_int, not builtin_type_ada_int.
2004-09-19 00:23:23 +02:00
{
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
return parse_type (par_state)->builtin_int;
* ada-exp.y (type_int): New function to add layer of abstraction around references to expression types. (type_long): Ditto. (type_long_long): Ditto. (type_float): Ditto. (type_double): Ditto. (type_long_double): Ditto. (type_char): Ditto. (type_system_address): Ditto. (simple_exp): Use type_* functions in place of builtin_* variables. (exp): Ditto. (write_var_from_name): Ditto. (write_object_renaming): Ditto. * ada-lang.c (ada_create_fundamental_type): Remove redundant declaration. (build_ada_types): Remove, replacing with... (ada_language_arch_info): New function to initialize primitive type vector in language_arch_info. (ada_array_length): Remove use of builtin_type_ada_int. (value_pos_atr): Ditto. (ada_evaluate_subexp): Ditto. (builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long, builtin_type_ada_long_long, builtin_type_ada_char, builtin_type_ada_float, builtin_type_ada_double, builtin_type_ada_long_double, builtin_type_ada_natural, builtin_type_ada_positive, builtin_type_ada_system_address): Remove. (ada_builtin_types): Remove. (ada_language_defn): Remove entries for la_builtin_type_vector and string_char_type and use ada_language_arch_info. (_initialize_ada_language): Do type-vector initialization along the lines of c-lang.c. (ada_create_fundamental_type): Break up line. (ada_dump_symtab): Remove unused function. (enum ada_primitive_types): Define. * ada-lang.h (builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long,builtin_type_ada_long_long,builtin_type_ada_char, builtin_type_ada_float, builtin_type_ada_double, builtin_type_ada_long_double, builtin_type_ada_natural, builtin_type_ada_positive, builtin_type_ada_system_address): Remove. * ada-lex.l: Use type_* functions in place of builtin_* variables. (processInt): Ditto. (processReal): Ditto. (name_lookup): Ditto. * ada-typeprint.c (print_range): Use builtin_type_int, not builtin_type_ada_int.
2004-09-19 00:23:23 +02:00
}
static struct type *
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
type_long (struct parser_state *par_state)
* ada-exp.y (type_int): New function to add layer of abstraction around references to expression types. (type_long): Ditto. (type_long_long): Ditto. (type_float): Ditto. (type_double): Ditto. (type_long_double): Ditto. (type_char): Ditto. (type_system_address): Ditto. (simple_exp): Use type_* functions in place of builtin_* variables. (exp): Ditto. (write_var_from_name): Ditto. (write_object_renaming): Ditto. * ada-lang.c (ada_create_fundamental_type): Remove redundant declaration. (build_ada_types): Remove, replacing with... (ada_language_arch_info): New function to initialize primitive type vector in language_arch_info. (ada_array_length): Remove use of builtin_type_ada_int. (value_pos_atr): Ditto. (ada_evaluate_subexp): Ditto. (builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long, builtin_type_ada_long_long, builtin_type_ada_char, builtin_type_ada_float, builtin_type_ada_double, builtin_type_ada_long_double, builtin_type_ada_natural, builtin_type_ada_positive, builtin_type_ada_system_address): Remove. (ada_builtin_types): Remove. (ada_language_defn): Remove entries for la_builtin_type_vector and string_char_type and use ada_language_arch_info. (_initialize_ada_language): Do type-vector initialization along the lines of c-lang.c. (ada_create_fundamental_type): Break up line. (ada_dump_symtab): Remove unused function. (enum ada_primitive_types): Define. * ada-lang.h (builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long,builtin_type_ada_long_long,builtin_type_ada_char, builtin_type_ada_float, builtin_type_ada_double, builtin_type_ada_long_double, builtin_type_ada_natural, builtin_type_ada_positive, builtin_type_ada_system_address): Remove. * ada-lex.l: Use type_* functions in place of builtin_* variables. (processInt): Ditto. (processReal): Ditto. (name_lookup): Ditto. * ada-typeprint.c (print_range): Use builtin_type_int, not builtin_type_ada_int.
2004-09-19 00:23:23 +02:00
{
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
return parse_type (par_state)->builtin_long;
* ada-exp.y (type_int): New function to add layer of abstraction around references to expression types. (type_long): Ditto. (type_long_long): Ditto. (type_float): Ditto. (type_double): Ditto. (type_long_double): Ditto. (type_char): Ditto. (type_system_address): Ditto. (simple_exp): Use type_* functions in place of builtin_* variables. (exp): Ditto. (write_var_from_name): Ditto. (write_object_renaming): Ditto. * ada-lang.c (ada_create_fundamental_type): Remove redundant declaration. (build_ada_types): Remove, replacing with... (ada_language_arch_info): New function to initialize primitive type vector in language_arch_info. (ada_array_length): Remove use of builtin_type_ada_int. (value_pos_atr): Ditto. (ada_evaluate_subexp): Ditto. (builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long, builtin_type_ada_long_long, builtin_type_ada_char, builtin_type_ada_float, builtin_type_ada_double, builtin_type_ada_long_double, builtin_type_ada_natural, builtin_type_ada_positive, builtin_type_ada_system_address): Remove. (ada_builtin_types): Remove. (ada_language_defn): Remove entries for la_builtin_type_vector and string_char_type and use ada_language_arch_info. (_initialize_ada_language): Do type-vector initialization along the lines of c-lang.c. (ada_create_fundamental_type): Break up line. (ada_dump_symtab): Remove unused function. (enum ada_primitive_types): Define. * ada-lang.h (builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long,builtin_type_ada_long_long,builtin_type_ada_char, builtin_type_ada_float, builtin_type_ada_double, builtin_type_ada_long_double, builtin_type_ada_natural, builtin_type_ada_positive, builtin_type_ada_system_address): Remove. * ada-lex.l: Use type_* functions in place of builtin_* variables. (processInt): Ditto. (processReal): Ditto. (name_lookup): Ditto. * ada-typeprint.c (print_range): Use builtin_type_int, not builtin_type_ada_int.
2004-09-19 00:23:23 +02:00
}
static struct type *
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
type_long_long (struct parser_state *par_state)
* ada-exp.y (type_int): New function to add layer of abstraction around references to expression types. (type_long): Ditto. (type_long_long): Ditto. (type_float): Ditto. (type_double): Ditto. (type_long_double): Ditto. (type_char): Ditto. (type_system_address): Ditto. (simple_exp): Use type_* functions in place of builtin_* variables. (exp): Ditto. (write_var_from_name): Ditto. (write_object_renaming): Ditto. * ada-lang.c (ada_create_fundamental_type): Remove redundant declaration. (build_ada_types): Remove, replacing with... (ada_language_arch_info): New function to initialize primitive type vector in language_arch_info. (ada_array_length): Remove use of builtin_type_ada_int. (value_pos_atr): Ditto. (ada_evaluate_subexp): Ditto. (builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long, builtin_type_ada_long_long, builtin_type_ada_char, builtin_type_ada_float, builtin_type_ada_double, builtin_type_ada_long_double, builtin_type_ada_natural, builtin_type_ada_positive, builtin_type_ada_system_address): Remove. (ada_builtin_types): Remove. (ada_language_defn): Remove entries for la_builtin_type_vector and string_char_type and use ada_language_arch_info. (_initialize_ada_language): Do type-vector initialization along the lines of c-lang.c. (ada_create_fundamental_type): Break up line. (ada_dump_symtab): Remove unused function. (enum ada_primitive_types): Define. * ada-lang.h (builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long,builtin_type_ada_long_long,builtin_type_ada_char, builtin_type_ada_float, builtin_type_ada_double, builtin_type_ada_long_double, builtin_type_ada_natural, builtin_type_ada_positive, builtin_type_ada_system_address): Remove. * ada-lex.l: Use type_* functions in place of builtin_* variables. (processInt): Ditto. (processReal): Ditto. (name_lookup): Ditto. * ada-typeprint.c (print_range): Use builtin_type_int, not builtin_type_ada_int.
2004-09-19 00:23:23 +02:00
{
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
return parse_type (par_state)->builtin_long_long;
* ada-exp.y (type_int): New function to add layer of abstraction around references to expression types. (type_long): Ditto. (type_long_long): Ditto. (type_float): Ditto. (type_double): Ditto. (type_long_double): Ditto. (type_char): Ditto. (type_system_address): Ditto. (simple_exp): Use type_* functions in place of builtin_* variables. (exp): Ditto. (write_var_from_name): Ditto. (write_object_renaming): Ditto. * ada-lang.c (ada_create_fundamental_type): Remove redundant declaration. (build_ada_types): Remove, replacing with... (ada_language_arch_info): New function to initialize primitive type vector in language_arch_info. (ada_array_length): Remove use of builtin_type_ada_int. (value_pos_atr): Ditto. (ada_evaluate_subexp): Ditto. (builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long, builtin_type_ada_long_long, builtin_type_ada_char, builtin_type_ada_float, builtin_type_ada_double, builtin_type_ada_long_double, builtin_type_ada_natural, builtin_type_ada_positive, builtin_type_ada_system_address): Remove. (ada_builtin_types): Remove. (ada_language_defn): Remove entries for la_builtin_type_vector and string_char_type and use ada_language_arch_info. (_initialize_ada_language): Do type-vector initialization along the lines of c-lang.c. (ada_create_fundamental_type): Break up line. (ada_dump_symtab): Remove unused function. (enum ada_primitive_types): Define. * ada-lang.h (builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long,builtin_type_ada_long_long,builtin_type_ada_char, builtin_type_ada_float, builtin_type_ada_double, builtin_type_ada_long_double, builtin_type_ada_natural, builtin_type_ada_positive, builtin_type_ada_system_address): Remove. * ada-lex.l: Use type_* functions in place of builtin_* variables. (processInt): Ditto. (processReal): Ditto. (name_lookup): Ditto. * ada-typeprint.c (print_range): Use builtin_type_int, not builtin_type_ada_int.
2004-09-19 00:23:23 +02:00
}
static struct type *
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
type_long_double (struct parser_state *par_state)
* ada-exp.y (type_int): New function to add layer of abstraction around references to expression types. (type_long): Ditto. (type_long_long): Ditto. (type_float): Ditto. (type_double): Ditto. (type_long_double): Ditto. (type_char): Ditto. (type_system_address): Ditto. (simple_exp): Use type_* functions in place of builtin_* variables. (exp): Ditto. (write_var_from_name): Ditto. (write_object_renaming): Ditto. * ada-lang.c (ada_create_fundamental_type): Remove redundant declaration. (build_ada_types): Remove, replacing with... (ada_language_arch_info): New function to initialize primitive type vector in language_arch_info. (ada_array_length): Remove use of builtin_type_ada_int. (value_pos_atr): Ditto. (ada_evaluate_subexp): Ditto. (builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long, builtin_type_ada_long_long, builtin_type_ada_char, builtin_type_ada_float, builtin_type_ada_double, builtin_type_ada_long_double, builtin_type_ada_natural, builtin_type_ada_positive, builtin_type_ada_system_address): Remove. (ada_builtin_types): Remove. (ada_language_defn): Remove entries for la_builtin_type_vector and string_char_type and use ada_language_arch_info. (_initialize_ada_language): Do type-vector initialization along the lines of c-lang.c. (ada_create_fundamental_type): Break up line. (ada_dump_symtab): Remove unused function. (enum ada_primitive_types): Define. * ada-lang.h (builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long,builtin_type_ada_long_long,builtin_type_ada_char, builtin_type_ada_float, builtin_type_ada_double, builtin_type_ada_long_double, builtin_type_ada_natural, builtin_type_ada_positive, builtin_type_ada_system_address): Remove. * ada-lex.l: Use type_* functions in place of builtin_* variables. (processInt): Ditto. (processReal): Ditto. (name_lookup): Ditto. * ada-typeprint.c (print_range): Use builtin_type_int, not builtin_type_ada_int.
2004-09-19 00:23:23 +02:00
{
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
return parse_type (par_state)->builtin_long_double;
* ada-exp.y (type_int): New function to add layer of abstraction around references to expression types. (type_long): Ditto. (type_long_long): Ditto. (type_float): Ditto. (type_double): Ditto. (type_long_double): Ditto. (type_char): Ditto. (type_system_address): Ditto. (simple_exp): Use type_* functions in place of builtin_* variables. (exp): Ditto. (write_var_from_name): Ditto. (write_object_renaming): Ditto. * ada-lang.c (ada_create_fundamental_type): Remove redundant declaration. (build_ada_types): Remove, replacing with... (ada_language_arch_info): New function to initialize primitive type vector in language_arch_info. (ada_array_length): Remove use of builtin_type_ada_int. (value_pos_atr): Ditto. (ada_evaluate_subexp): Ditto. (builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long, builtin_type_ada_long_long, builtin_type_ada_char, builtin_type_ada_float, builtin_type_ada_double, builtin_type_ada_long_double, builtin_type_ada_natural, builtin_type_ada_positive, builtin_type_ada_system_address): Remove. (ada_builtin_types): Remove. (ada_language_defn): Remove entries for la_builtin_type_vector and string_char_type and use ada_language_arch_info. (_initialize_ada_language): Do type-vector initialization along the lines of c-lang.c. (ada_create_fundamental_type): Break up line. (ada_dump_symtab): Remove unused function. (enum ada_primitive_types): Define. * ada-lang.h (builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long,builtin_type_ada_long_long,builtin_type_ada_char, builtin_type_ada_float, builtin_type_ada_double, builtin_type_ada_long_double, builtin_type_ada_natural, builtin_type_ada_positive, builtin_type_ada_system_address): Remove. * ada-lex.l: Use type_* functions in place of builtin_* variables. (processInt): Ditto. (processReal): Ditto. (name_lookup): Ditto. * ada-typeprint.c (print_range): Use builtin_type_int, not builtin_type_ada_int.
2004-09-19 00:23:23 +02:00
}
static struct type *
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
type_char (struct parser_state *par_state)
* ada-exp.y (type_int): New function to add layer of abstraction around references to expression types. (type_long): Ditto. (type_long_long): Ditto. (type_float): Ditto. (type_double): Ditto. (type_long_double): Ditto. (type_char): Ditto. (type_system_address): Ditto. (simple_exp): Use type_* functions in place of builtin_* variables. (exp): Ditto. (write_var_from_name): Ditto. (write_object_renaming): Ditto. * ada-lang.c (ada_create_fundamental_type): Remove redundant declaration. (build_ada_types): Remove, replacing with... (ada_language_arch_info): New function to initialize primitive type vector in language_arch_info. (ada_array_length): Remove use of builtin_type_ada_int. (value_pos_atr): Ditto. (ada_evaluate_subexp): Ditto. (builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long, builtin_type_ada_long_long, builtin_type_ada_char, builtin_type_ada_float, builtin_type_ada_double, builtin_type_ada_long_double, builtin_type_ada_natural, builtin_type_ada_positive, builtin_type_ada_system_address): Remove. (ada_builtin_types): Remove. (ada_language_defn): Remove entries for la_builtin_type_vector and string_char_type and use ada_language_arch_info. (_initialize_ada_language): Do type-vector initialization along the lines of c-lang.c. (ada_create_fundamental_type): Break up line. (ada_dump_symtab): Remove unused function. (enum ada_primitive_types): Define. * ada-lang.h (builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long,builtin_type_ada_long_long,builtin_type_ada_char, builtin_type_ada_float, builtin_type_ada_double, builtin_type_ada_long_double, builtin_type_ada_natural, builtin_type_ada_positive, builtin_type_ada_system_address): Remove. * ada-lex.l: Use type_* functions in place of builtin_* variables. (processInt): Ditto. (processReal): Ditto. (name_lookup): Ditto. * ada-typeprint.c (print_range): Use builtin_type_int, not builtin_type_ada_int.
2004-09-19 00:23:23 +02:00
{
return language_string_char_type (par_state->language (),
par_state->gdbarch ());
* ada-exp.y (type_int): New function to add layer of abstraction around references to expression types. (type_long): Ditto. (type_long_long): Ditto. (type_float): Ditto. (type_double): Ditto. (type_long_double): Ditto. (type_char): Ditto. (type_system_address): Ditto. (simple_exp): Use type_* functions in place of builtin_* variables. (exp): Ditto. (write_var_from_name): Ditto. (write_object_renaming): Ditto. * ada-lang.c (ada_create_fundamental_type): Remove redundant declaration. (build_ada_types): Remove, replacing with... (ada_language_arch_info): New function to initialize primitive type vector in language_arch_info. (ada_array_length): Remove use of builtin_type_ada_int. (value_pos_atr): Ditto. (ada_evaluate_subexp): Ditto. (builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long, builtin_type_ada_long_long, builtin_type_ada_char, builtin_type_ada_float, builtin_type_ada_double, builtin_type_ada_long_double, builtin_type_ada_natural, builtin_type_ada_positive, builtin_type_ada_system_address): Remove. (ada_builtin_types): Remove. (ada_language_defn): Remove entries for la_builtin_type_vector and string_char_type and use ada_language_arch_info. (_initialize_ada_language): Do type-vector initialization along the lines of c-lang.c. (ada_create_fundamental_type): Break up line. (ada_dump_symtab): Remove unused function. (enum ada_primitive_types): Define. * ada-lang.h (builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long,builtin_type_ada_long_long,builtin_type_ada_char, builtin_type_ada_float, builtin_type_ada_double, builtin_type_ada_long_double, builtin_type_ada_natural, builtin_type_ada_positive, builtin_type_ada_system_address): Remove. * ada-lex.l: Use type_* functions in place of builtin_* variables. (processInt): Ditto. (processReal): Ditto. (name_lookup): Ditto. * ada-typeprint.c (print_range): Use builtin_type_int, not builtin_type_ada_int.
2004-09-19 00:23:23 +02:00
}
static struct type *
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
type_boolean (struct parser_state *par_state)
{
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
return parse_type (par_state)->builtin_bool;
}
* ada-exp.y (type_int): New function to add layer of abstraction around references to expression types. (type_long): Ditto. (type_long_long): Ditto. (type_float): Ditto. (type_double): Ditto. (type_long_double): Ditto. (type_char): Ditto. (type_system_address): Ditto. (simple_exp): Use type_* functions in place of builtin_* variables. (exp): Ditto. (write_var_from_name): Ditto. (write_object_renaming): Ditto. * ada-lang.c (ada_create_fundamental_type): Remove redundant declaration. (build_ada_types): Remove, replacing with... (ada_language_arch_info): New function to initialize primitive type vector in language_arch_info. (ada_array_length): Remove use of builtin_type_ada_int. (value_pos_atr): Ditto. (ada_evaluate_subexp): Ditto. (builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long, builtin_type_ada_long_long, builtin_type_ada_char, builtin_type_ada_float, builtin_type_ada_double, builtin_type_ada_long_double, builtin_type_ada_natural, builtin_type_ada_positive, builtin_type_ada_system_address): Remove. (ada_builtin_types): Remove. (ada_language_defn): Remove entries for la_builtin_type_vector and string_char_type and use ada_language_arch_info. (_initialize_ada_language): Do type-vector initialization along the lines of c-lang.c. (ada_create_fundamental_type): Break up line. (ada_dump_symtab): Remove unused function. (enum ada_primitive_types): Define. * ada-lang.h (builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long,builtin_type_ada_long_long,builtin_type_ada_char, builtin_type_ada_float, builtin_type_ada_double, builtin_type_ada_long_double, builtin_type_ada_natural, builtin_type_ada_positive, builtin_type_ada_system_address): Remove. * ada-lex.l: Use type_* functions in place of builtin_* variables. (processInt): Ditto. (processReal): Ditto. (name_lookup): Ditto. * ada-typeprint.c (print_range): Use builtin_type_int, not builtin_type_ada_int.
2004-09-19 00:23:23 +02:00
static struct type *
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
type_system_address (struct parser_state *par_state)
* ada-exp.y (type_int): New function to add layer of abstraction around references to expression types. (type_long): Ditto. (type_long_long): Ditto. (type_float): Ditto. (type_double): Ditto. (type_long_double): Ditto. (type_char): Ditto. (type_system_address): Ditto. (simple_exp): Use type_* functions in place of builtin_* variables. (exp): Ditto. (write_var_from_name): Ditto. (write_object_renaming): Ditto. * ada-lang.c (ada_create_fundamental_type): Remove redundant declaration. (build_ada_types): Remove, replacing with... (ada_language_arch_info): New function to initialize primitive type vector in language_arch_info. (ada_array_length): Remove use of builtin_type_ada_int. (value_pos_atr): Ditto. (ada_evaluate_subexp): Ditto. (builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long, builtin_type_ada_long_long, builtin_type_ada_char, builtin_type_ada_float, builtin_type_ada_double, builtin_type_ada_long_double, builtin_type_ada_natural, builtin_type_ada_positive, builtin_type_ada_system_address): Remove. (ada_builtin_types): Remove. (ada_language_defn): Remove entries for la_builtin_type_vector and string_char_type and use ada_language_arch_info. (_initialize_ada_language): Do type-vector initialization along the lines of c-lang.c. (ada_create_fundamental_type): Break up line. (ada_dump_symtab): Remove unused function. (enum ada_primitive_types): Define. * ada-lang.h (builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long,builtin_type_ada_long_long,builtin_type_ada_char, builtin_type_ada_float, builtin_type_ada_double, builtin_type_ada_long_double, builtin_type_ada_natural, builtin_type_ada_positive, builtin_type_ada_system_address): Remove. * ada-lex.l: Use type_* functions in place of builtin_* variables. (processInt): Ditto. (processReal): Ditto. (name_lookup): Ditto. * ada-typeprint.c (print_range): Use builtin_type_int, not builtin_type_ada_int.
2004-09-19 00:23:23 +02:00
{
struct type *type
= language_lookup_primitive_type (par_state->language (),
par_state->gdbarch (),
"system__address");
Remove `expout*' globals from parser-defs.h This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
2014-03-27 23:10:40 +01:00
return type != NULL ? type : parse_type (par_state)->builtin_data_ptr;
* ada-exp.y (type_int): New function to add layer of abstraction around references to expression types. (type_long): Ditto. (type_long_long): Ditto. (type_float): Ditto. (type_double): Ditto. (type_long_double): Ditto. (type_char): Ditto. (type_system_address): Ditto. (simple_exp): Use type_* functions in place of builtin_* variables. (exp): Ditto. (write_var_from_name): Ditto. (write_object_renaming): Ditto. * ada-lang.c (ada_create_fundamental_type): Remove redundant declaration. (build_ada_types): Remove, replacing with... (ada_language_arch_info): New function to initialize primitive type vector in language_arch_info. (ada_array_length): Remove use of builtin_type_ada_int. (value_pos_atr): Ditto. (ada_evaluate_subexp): Ditto. (builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long, builtin_type_ada_long_long, builtin_type_ada_char, builtin_type_ada_float, builtin_type_ada_double, builtin_type_ada_long_double, builtin_type_ada_natural, builtin_type_ada_positive, builtin_type_ada_system_address): Remove. (ada_builtin_types): Remove. (ada_language_defn): Remove entries for la_builtin_type_vector and string_char_type and use ada_language_arch_info. (_initialize_ada_language): Do type-vector initialization along the lines of c-lang.c. (ada_create_fundamental_type): Break up line. (ada_dump_symtab): Remove unused function. (enum ada_primitive_types): Define. * ada-lang.h (builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long,builtin_type_ada_long_long,builtin_type_ada_char, builtin_type_ada_float, builtin_type_ada_double, builtin_type_ada_long_double, builtin_type_ada_natural, builtin_type_ada_positive, builtin_type_ada_system_address): Remove. * ada-lex.l: Use type_* functions in place of builtin_* variables. (processInt): Ditto. (processReal): Ditto. (name_lookup): Ditto. * ada-typeprint.c (print_range): Use builtin_type_int, not builtin_type_ada_int.
2004-09-19 00:23:23 +02:00
}
gdb: add back declarations for _initialize functions I'd like to enable the -Wmissing-declarations warning. However, it warns for every _initialize function, for example: CXX dcache.o /home/smarchi/src/binutils-gdb/gdb/dcache.c: In function ‘void _initialize_dcache()’: /home/smarchi/src/binutils-gdb/gdb/dcache.c:688:1: error: no previous declaration for ‘void _initialize_dcache()’ [-Werror=missing-declarations] _initialize_dcache (void) ^~~~~~~~~~~~~~~~~~ The only practical way forward I found is to add back the declarations, which were removed by this commit: commit 481695ed5f6e0a8a9c9c50bfac1cdd2b3151e6c9 Author: John Baldwin <jhb@FreeBSD.org> Date: Sat Sep 9 11:02:37 2017 -0700 Remove unnecessary function prototypes. I don't think it's a big problem to have the declarations for these functions, but if anybody has a better solution for this, I'll be happy to use it. gdb/ChangeLog: * aarch64-fbsd-nat.c (_initialize_aarch64_fbsd_nat): Add declaration. * aarch64-fbsd-tdep.c (_initialize_aarch64_fbsd_tdep): Add declaration. * aarch64-linux-nat.c (_initialize_aarch64_linux_nat): Add declaration. * aarch64-linux-tdep.c (_initialize_aarch64_linux_tdep): Add declaration. * aarch64-newlib-tdep.c (_initialize_aarch64_newlib_tdep): Add declaration. * aarch64-tdep.c (_initialize_aarch64_tdep): Add declaration. * ada-exp.y (_initialize_ada_exp): Add declaration. * ada-lang.c (_initialize_ada_language): Add declaration. * ada-tasks.c (_initialize_tasks): Add declaration. * agent.c (_initialize_agent): Add declaration. * aix-thread.c (_initialize_aix_thread): Add declaration. * alpha-bsd-nat.c (_initialize_alphabsd_nat): Add declaration. * alpha-linux-nat.c (_initialize_alpha_linux_nat): Add declaration. * alpha-linux-tdep.c (_initialize_alpha_linux_tdep): Add declaration. * alpha-nbsd-tdep.c (_initialize_alphanbsd_tdep): Add declaration. * alpha-obsd-tdep.c (_initialize_alphaobsd_tdep): Add declaration. * alpha-tdep.c (_initialize_alpha_tdep): Add declaration. * amd64-darwin-tdep.c (_initialize_amd64_darwin_tdep): Add declaration. * amd64-dicos-tdep.c (_initialize_amd64_dicos_tdep): Add declaration. * amd64-fbsd-nat.c (_initialize_amd64fbsd_nat): Add declaration. * amd64-fbsd-tdep.c (_initialize_amd64fbsd_tdep): Add declaration. * amd64-linux-nat.c (_initialize_amd64_linux_nat): Add declaration. * amd64-linux-tdep.c (_initialize_amd64_linux_tdep): Add declaration. * amd64-nbsd-nat.c (_initialize_amd64nbsd_nat): Add declaration. * amd64-nbsd-tdep.c (_initialize_amd64nbsd_tdep): Add declaration. * amd64-obsd-nat.c (_initialize_amd64obsd_nat): Add declaration. * amd64-obsd-tdep.c (_initialize_amd64obsd_tdep): Add declaration. * amd64-sol2-tdep.c (_initialize_amd64_sol2_tdep): Add declaration. * amd64-tdep.c (_initialize_amd64_tdep): Add declaration. * amd64-windows-nat.c (_initialize_amd64_windows_nat): Add declaration. * amd64-windows-tdep.c (_initialize_amd64_windows_tdep): Add declaration. * annotate.c (_initialize_annotate): Add declaration. * arc-newlib-tdep.c (_initialize_arc_newlib_tdep): Add declaration. * arc-tdep.c (_initialize_arc_tdep): Add declaration. * arch-utils.c (_initialize_gdbarch_utils): Add declaration. * arm-fbsd-nat.c (_initialize_arm_fbsd_nat): Add declaration. * arm-fbsd-tdep.c (_initialize_arm_fbsd_tdep): Add declaration. * arm-linux-nat.c (_initialize_arm_linux_nat): Add declaration. * arm-linux-tdep.c (_initialize_arm_linux_tdep): Add declaration. * arm-nbsd-nat.c (_initialize_arm_netbsd_nat): Add declaration. * arm-nbsd-tdep.c (_initialize_arm_netbsd_tdep): Add declaration. * arm-obsd-tdep.c (_initialize_armobsd_tdep): Add declaration. * arm-pikeos-tdep.c (_initialize_arm_pikeos_tdep): Add declaration. * arm-symbian-tdep.c (_initialize_arm_symbian_tdep): Add declaration. * arm-tdep.c (_initialize_arm_tdep): Add declaration. * arm-wince-tdep.c (_initialize_arm_wince_tdep): Add declaration. * auto-load.c (_initialize_auto_load): Add declaration. * auxv.c (_initialize_auxv): Add declaration. * avr-tdep.c (_initialize_avr_tdep): Add declaration. * ax-gdb.c (_initialize_ax_gdb): Add declaration. * bfin-linux-tdep.c (_initialize_bfin_linux_tdep): Add declaration. * bfin-tdep.c (_initialize_bfin_tdep): Add declaration. * break-catch-sig.c (_initialize_break_catch_sig): Add declaration. * break-catch-syscall.c (_initialize_break_catch_syscall): Add declaration. * break-catch-throw.c (_initialize_break_catch_throw): Add declaration. * breakpoint.c (_initialize_breakpoint): Add declaration. * bsd-uthread.c (_initialize_bsd_uthread): Add declaration. * btrace.c (_initialize_btrace): Add declaration. * charset.c (_initialize_charset): Add declaration. * cli/cli-cmds.c (_initialize_cli_cmds): Add declaration. * cli/cli-dump.c (_initialize_cli_dump): Add declaration. * cli/cli-interp.c (_initialize_cli_interp): Add declaration. * cli/cli-logging.c (_initialize_cli_logging): Add declaration. * cli/cli-script.c (_initialize_cli_script): Add declaration. * cli/cli-style.c (_initialize_cli_style): Add declaration. * coff-pe-read.c (_initialize_coff_pe_read): Add declaration. * coffread.c (_initialize_coffread): Add declaration. * compile/compile-cplus-types.c (_initialize_compile_cplus_types): Add declaration. * compile/compile.c (_initialize_compile): Add declaration. * complaints.c (_initialize_complaints): Add declaration. * completer.c (_initialize_completer): Add declaration. * copying.c (_initialize_copying): Add declaration. * corefile.c (_initialize_core): Add declaration. * corelow.c (_initialize_corelow): Add declaration. * cp-abi.c (_initialize_cp_abi): Add declaration. * cp-namespace.c (_initialize_cp_namespace): Add declaration. * cp-support.c (_initialize_cp_support): Add declaration. * cp-valprint.c (_initialize_cp_valprint): Add declaration. * cris-linux-tdep.c (_initialize_cris_linux_tdep): Add declaration. * cris-tdep.c (_initialize_cris_tdep): Add declaration. * csky-linux-tdep.c (_initialize_csky_linux_tdep): Add declaration. * csky-tdep.c (_initialize_csky_tdep): Add declaration. * ctfread.c (_initialize_ctfread): Add declaration. * d-lang.c (_initialize_d_language): Add declaration. * darwin-nat-info.c (_initialize_darwin_info_commands): Add declaration. * darwin-nat.c (_initialize_darwin_nat): Add declaration. * dbxread.c (_initialize_dbxread): Add declaration. * dcache.c (_initialize_dcache): Add declaration. * disasm-selftests.c (_initialize_disasm_selftests): Add declaration. * disasm.c (_initialize_disasm): Add declaration. * dtrace-probe.c (_initialize_dtrace_probe): Add declaration. * dummy-frame.c (_initialize_dummy_frame): Add declaration. * dwarf-index-cache.c (_initialize_index_cache): Add declaration. * dwarf-index-write.c (_initialize_dwarf_index_write): Add declaration. * dwarf2-frame-tailcall.c (_initialize_tailcall_frame): Add declaration. * dwarf2-frame.c (_initialize_dwarf2_frame): Add declaration. * dwarf2expr.c (_initialize_dwarf2expr): Add declaration. * dwarf2loc.c (_initialize_dwarf2loc): Add declaration. * dwarf2read.c (_initialize_dwarf2_read): Add declaration. * elfread.c (_initialize_elfread): Add declaration. * exec.c (_initialize_exec): Add declaration. * extension.c (_initialize_extension): Add declaration. * f-lang.c (_initialize_f_language): Add declaration. * f-valprint.c (_initialize_f_valprint): Add declaration. * fbsd-nat.c (_initialize_fbsd_nat): Add declaration. * fbsd-tdep.c (_initialize_fbsd_tdep): Add declaration. * filesystem.c (_initialize_filesystem): Add declaration. * findcmd.c (_initialize_mem_search): Add declaration. * findvar.c (_initialize_findvar): Add declaration. * fork-child.c (_initialize_fork_child): Add declaration. * frame-base.c (_initialize_frame_base): Add declaration. * frame-unwind.c (_initialize_frame_unwind): Add declaration. * frame.c (_initialize_frame): Add declaration. * frv-linux-tdep.c (_initialize_frv_linux_tdep): Add declaration. * frv-tdep.c (_initialize_frv_tdep): Add declaration. * ft32-tdep.c (_initialize_ft32_tdep): Add declaration. * gcore.c (_initialize_gcore): Add declaration. * gdb-demangle.c (_initialize_gdb_demangle): Add declaration. * gdb_bfd.c (_initialize_gdb_bfd): Add declaration. * gdbarch-selftests.c (_initialize_gdbarch_selftests): Add declaration. * gdbarch.c (_initialize_gdbarch): Add declaration. * gdbtypes.c (_initialize_gdbtypes): Add declaration. * gnu-nat.c (_initialize_gnu_nat): Add declaration. * gnu-v2-abi.c (_initialize_gnu_v2_abi): Add declaration. * gnu-v3-abi.c (_initialize_gnu_v3_abi): Add declaration. * go-lang.c (_initialize_go_language): Add declaration. * go32-nat.c (_initialize_go32_nat): Add declaration. * guile/guile.c (_initialize_guile): Add declaration. * h8300-tdep.c (_initialize_h8300_tdep): Add declaration. * hppa-linux-nat.c (_initialize_hppa_linux_nat): Add declaration. * hppa-linux-tdep.c (_initialize_hppa_linux_tdep): Add declaration. * hppa-nbsd-nat.c (_initialize_hppanbsd_nat): Add declaration. * hppa-nbsd-tdep.c (_initialize_hppanbsd_tdep): Add declaration. * hppa-obsd-nat.c (_initialize_hppaobsd_nat): Add declaration. * hppa-obsd-tdep.c (_initialize_hppabsd_tdep): Add declaration. * hppa-tdep.c (_initialize_hppa_tdep): Add declaration. * i386-bsd-nat.c (_initialize_i386bsd_nat): Add declaration. * i386-cygwin-tdep.c (_initialize_i386_cygwin_tdep): Add declaration. * i386-darwin-nat.c (_initialize_i386_darwin_nat): Add declaration. * i386-darwin-tdep.c (_initialize_i386_darwin_tdep): Add declaration. * i386-dicos-tdep.c (_initialize_i386_dicos_tdep): Add declaration. * i386-fbsd-nat.c (_initialize_i386fbsd_nat): Add declaration. * i386-fbsd-tdep.c (_initialize_i386fbsd_tdep): Add declaration. * i386-gnu-nat.c (_initialize_i386gnu_nat): Add declaration. * i386-gnu-tdep.c (_initialize_i386gnu_tdep): Add declaration. * i386-go32-tdep.c (_initialize_i386_go32_tdep): Add declaration. * i386-linux-nat.c (_initialize_i386_linux_nat): Add declaration. * i386-linux-tdep.c (_initialize_i386_linux_tdep): Add declaration. * i386-nbsd-nat.c (_initialize_i386nbsd_nat): Add declaration. * i386-nbsd-tdep.c (_initialize_i386nbsd_tdep): Add declaration. * i386-nto-tdep.c (_initialize_i386nto_tdep): Add declaration. * i386-obsd-nat.c (_initialize_i386obsd_nat): Add declaration. * i386-obsd-tdep.c (_initialize_i386obsd_tdep): Add declaration. * i386-sol2-nat.c (_initialize_amd64_sol2_nat): Add declaration. * i386-sol2-tdep.c (_initialize_i386_sol2_tdep): Add declaration. * i386-tdep.c (_initialize_i386_tdep): Add declaration. * i386-windows-nat.c (_initialize_i386_windows_nat): Add declaration. * ia64-libunwind-tdep.c (_initialize_libunwind_frame): Add declaration. * ia64-linux-nat.c (_initialize_ia64_linux_nat): Add declaration. * ia64-linux-tdep.c (_initialize_ia64_linux_tdep): Add declaration. * ia64-tdep.c (_initialize_ia64_tdep): Add declaration. * ia64-vms-tdep.c (_initialize_ia64_vms_tdep): Add declaration. * infcall.c (_initialize_infcall): Add declaration. * infcmd.c (_initialize_infcmd): Add declaration. * inflow.c (_initialize_inflow): Add declaration. * infrun.c (_initialize_infrun): Add declaration. * interps.c (_initialize_interpreter): Add declaration. * iq2000-tdep.c (_initialize_iq2000_tdep): Add declaration. * jit.c (_initialize_jit): Add declaration. * language.c (_initialize_language): Add declaration. * linux-fork.c (_initialize_linux_fork): Add declaration. * linux-nat.c (_initialize_linux_nat): Add declaration. * linux-tdep.c (_initialize_linux_tdep): Add declaration. * linux-thread-db.c (_initialize_thread_db): Add declaration. * lm32-tdep.c (_initialize_lm32_tdep): Add declaration. * m2-lang.c (_initialize_m2_language): Add declaration. * m32c-tdep.c (_initialize_m32c_tdep): Add declaration. * m32r-linux-nat.c (_initialize_m32r_linux_nat): Add declaration. * m32r-linux-tdep.c (_initialize_m32r_linux_tdep): Add declaration. * m32r-tdep.c (_initialize_m32r_tdep): Add declaration. * m68hc11-tdep.c (_initialize_m68hc11_tdep): Add declaration. * m68k-bsd-nat.c (_initialize_m68kbsd_nat): Add declaration. * m68k-bsd-tdep.c (_initialize_m68kbsd_tdep): Add declaration. * m68k-linux-nat.c (_initialize_m68k_linux_nat): Add declaration. * m68k-linux-tdep.c (_initialize_m68k_linux_tdep): Add declaration. * m68k-tdep.c (_initialize_m68k_tdep): Add declaration. * machoread.c (_initialize_machoread): Add declaration. * macrocmd.c (_initialize_macrocmd): Add declaration. * macroscope.c (_initialize_macroscope): Add declaration. * maint-test-options.c (_initialize_maint_test_options): Add declaration. * maint-test-settings.c (_initialize_maint_test_settings): Add declaration. * maint.c (_initialize_maint_cmds): Add declaration. * mdebugread.c (_initialize_mdebugread): Add declaration. * memattr.c (_initialize_mem): Add declaration. * mep-tdep.c (_initialize_mep_tdep): Add declaration. * mi/mi-cmd-env.c (_initialize_mi_cmd_env): Add declaration. * mi/mi-cmds.c (_initialize_mi_cmds): Add declaration. * mi/mi-interp.c (_initialize_mi_interp): Add declaration. * mi/mi-main.c (_initialize_mi_main): Add declaration. * microblaze-linux-tdep.c (_initialize_microblaze_linux_tdep): Add declaration. * microblaze-tdep.c (_initialize_microblaze_tdep): Add declaration. * mips-fbsd-nat.c (_initialize_mips_fbsd_nat): Add declaration. * mips-fbsd-tdep.c (_initialize_mips_fbsd_tdep): Add declaration. * mips-linux-nat.c (_initialize_mips_linux_nat): Add declaration. * mips-linux-tdep.c (_initialize_mips_linux_tdep): Add declaration. * mips-nbsd-nat.c (_initialize_mipsnbsd_nat): Add declaration. * mips-nbsd-tdep.c (_initialize_mipsnbsd_tdep): Add declaration. * mips-sde-tdep.c (_initialize_mips_sde_tdep): Add declaration. * mips-tdep.c (_initialize_mips_tdep): Add declaration. * mips64-obsd-nat.c (_initialize_mips64obsd_nat): Add declaration. * mips64-obsd-tdep.c (_initialize_mips64obsd_tdep): Add declaration. * mipsread.c (_initialize_mipsread): Add declaration. * mn10300-linux-tdep.c (_initialize_mn10300_linux_tdep): Add declaration. * mn10300-tdep.c (_initialize_mn10300_tdep): Add declaration. * moxie-tdep.c (_initialize_moxie_tdep): Add declaration. * msp430-tdep.c (_initialize_msp430_tdep): Add declaration. * nds32-tdep.c (_initialize_nds32_tdep): Add declaration. * nios2-linux-tdep.c (_initialize_nios2_linux_tdep): Add declaration. * nios2-tdep.c (_initialize_nios2_tdep): Add declaration. * nto-procfs.c (_initialize_procfs): Add declaration. * objc-lang.c (_initialize_objc_language): Add declaration. * observable.c (_initialize_observer): Add declaration. * opencl-lang.c (_initialize_opencl_language): Add declaration. * or1k-linux-tdep.c (_initialize_or1k_linux_tdep): Add declaration. * or1k-tdep.c (_initialize_or1k_tdep): Add declaration. * osabi.c (_initialize_gdb_osabi): Add declaration. * osdata.c (_initialize_osdata): Add declaration. * p-valprint.c (_initialize_pascal_valprint): Add declaration. * parse.c (_initialize_parse): Add declaration. * ppc-fbsd-nat.c (_initialize_ppcfbsd_nat): Add declaration. * ppc-fbsd-tdep.c (_initialize_ppcfbsd_tdep): Add declaration. * ppc-linux-nat.c (_initialize_ppc_linux_nat): Add declaration. * ppc-linux-tdep.c (_initialize_ppc_linux_tdep): Add declaration. * ppc-nbsd-nat.c (_initialize_ppcnbsd_nat): Add declaration. * ppc-nbsd-tdep.c (_initialize_ppcnbsd_tdep): Add declaration. * ppc-obsd-nat.c (_initialize_ppcobsd_nat): Add declaration. * ppc-obsd-tdep.c (_initialize_ppcobsd_tdep): Add declaration. * printcmd.c (_initialize_printcmd): Add declaration. * probe.c (_initialize_probe): Add declaration. * proc-api.c (_initialize_proc_api): Add declaration. * proc-events.c (_initialize_proc_events): Add declaration. * proc-service.c (_initialize_proc_service): Add declaration. * procfs.c (_initialize_procfs): Add declaration. * producer.c (_initialize_producer): Add declaration. * psymtab.c (_initialize_psymtab): Add declaration. * python/python.c (_initialize_python): Add declaration. * ravenscar-thread.c (_initialize_ravenscar): Add declaration. * record-btrace.c (_initialize_record_btrace): Add declaration. * record-full.c (_initialize_record_full): Add declaration. * record.c (_initialize_record): Add declaration. * regcache-dump.c (_initialize_regcache_dump): Add declaration. * regcache.c (_initialize_regcache): Add declaration. * reggroups.c (_initialize_reggroup): Add declaration. * remote-notif.c (_initialize_notif): Add declaration. * remote-sim.c (_initialize_remote_sim): Add declaration. * remote.c (_initialize_remote): Add declaration. * reverse.c (_initialize_reverse): Add declaration. * riscv-fbsd-nat.c (_initialize_riscv_fbsd_nat): Add declaration. * riscv-fbsd-tdep.c (_initialize_riscv_fbsd_tdep): Add declaration. * riscv-linux-nat.c (_initialize_riscv_linux_nat): Add declaration. * riscv-linux-tdep.c (_initialize_riscv_linux_tdep): Add declaration. * riscv-tdep.c (_initialize_riscv_tdep): Add declaration. * rl78-tdep.c (_initialize_rl78_tdep): Add declaration. * rs6000-aix-tdep.c (_initialize_rs6000_aix_tdep): Add declaration. * rs6000-lynx178-tdep.c (_initialize_rs6000_lynx178_tdep): Add declaration. * rs6000-nat.c (_initialize_rs6000_nat): Add declaration. * rs6000-tdep.c (_initialize_rs6000_tdep): Add declaration. * run-on-main-thread.c (_initialize_run_on_main_thread): Add declaration. * rust-exp.y (_initialize_rust_exp): Add declaration. * rx-tdep.c (_initialize_rx_tdep): Add declaration. * s12z-tdep.c (_initialize_s12z_tdep): Add declaration. * s390-linux-nat.c (_initialize_s390_nat): Add declaration. * s390-linux-tdep.c (_initialize_s390_linux_tdep): Add declaration. * s390-tdep.c (_initialize_s390_tdep): Add declaration. * score-tdep.c (_initialize_score_tdep): Add declaration. * ser-go32.c (_initialize_ser_dos): Add declaration. * ser-mingw.c (_initialize_ser_windows): Add declaration. * ser-pipe.c (_initialize_ser_pipe): Add declaration. * ser-tcp.c (_initialize_ser_tcp): Add declaration. * ser-uds.c (_initialize_ser_socket): Add declaration. * ser-unix.c (_initialize_ser_hardwire): Add declaration. * serial.c (_initialize_serial): Add declaration. * sh-linux-tdep.c (_initialize_sh_linux_tdep): Add declaration. * sh-nbsd-nat.c (_initialize_shnbsd_nat): Add declaration. * sh-nbsd-tdep.c (_initialize_shnbsd_tdep): Add declaration. * sh-tdep.c (_initialize_sh_tdep): Add declaration. * skip.c (_initialize_step_skip): Add declaration. * sol-thread.c (_initialize_sol_thread): Add declaration. * solib-aix.c (_initialize_solib_aix): Add declaration. * solib-darwin.c (_initialize_darwin_solib): Add declaration. * solib-dsbt.c (_initialize_dsbt_solib): Add declaration. * solib-frv.c (_initialize_frv_solib): Add declaration. * solib-svr4.c (_initialize_svr4_solib): Add declaration. * solib-target.c (_initialize_solib_target): Add declaration. * solib.c (_initialize_solib): Add declaration. * source-cache.c (_initialize_source_cache): Add declaration. * source.c (_initialize_source): Add declaration. * sparc-linux-nat.c (_initialize_sparc_linux_nat): Add declaration. * sparc-linux-tdep.c (_initialize_sparc_linux_tdep): Add declaration. * sparc-nat.c (_initialize_sparc_nat): Add declaration. * sparc-nbsd-nat.c (_initialize_sparcnbsd_nat): Add declaration. * sparc-nbsd-tdep.c (_initialize_sparcnbsd_tdep): Add declaration. * sparc-obsd-tdep.c (_initialize_sparc32obsd_tdep): Add declaration. * sparc-sol2-tdep.c (_initialize_sparc_sol2_tdep): Add declaration. * sparc-tdep.c (_initialize_sparc_tdep): Add declaration. * sparc64-fbsd-nat.c (_initialize_sparc64fbsd_nat): Add declaration. * sparc64-fbsd-tdep.c (_initialize_sparc64fbsd_tdep): Add declaration. * sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Add declaration. * sparc64-linux-tdep.c (_initialize_sparc64_linux_tdep): Add declaration. * sparc64-nat.c (_initialize_sparc64_nat): Add declaration. * sparc64-nbsd-nat.c (_initialize_sparc64nbsd_nat): Add declaration. * sparc64-nbsd-tdep.c (_initialize_sparc64nbsd_tdep): Add declaration. * sparc64-obsd-nat.c (_initialize_sparc64obsd_nat): Add declaration. * sparc64-obsd-tdep.c (_initialize_sparc64obsd_tdep): Add declaration. * sparc64-sol2-tdep.c (_initialize_sparc64_sol2_tdep): Add declaration. * sparc64-tdep.c (_initialize_sparc64_adi_tdep): Add declaration. * stabsread.c (_initialize_stabsread): Add declaration. * stack.c (_initialize_stack): Add declaration. * stap-probe.c (_initialize_stap_probe): Add declaration. * std-regs.c (_initialize_frame_reg): Add declaration. * symfile-debug.c (_initialize_symfile_debug): Add declaration. * symfile-mem.c (_initialize_symfile_mem): Add declaration. * symfile.c (_initialize_symfile): Add declaration. * symmisc.c (_initialize_symmisc): Add declaration. * symtab.c (_initialize_symtab): Add declaration. * target.c (_initialize_target): Add declaration. * target-connection.c (_initialize_target_connection): Add declaration. * target-dcache.c (_initialize_target_dcache): Add declaration. * target-descriptions.c (_initialize_target_descriptions): Add declaration. * thread.c (_initialize_thread): Add declaration. * tic6x-linux-tdep.c (_initialize_tic6x_linux_tdep): Add declaration. * tic6x-tdep.c (_initialize_tic6x_tdep): Add declaration. * tilegx-linux-nat.c (_initialize_tile_linux_nat): Add declaration. * tilegx-linux-tdep.c (_initialize_tilegx_linux_tdep): Add declaration. * tilegx-tdep.c (_initialize_tilegx_tdep): Add declaration. * tracectf.c (_initialize_ctf): Add declaration. * tracefile-tfile.c (_initialize_tracefile_tfile): Add declaration. * tracefile.c (_initialize_tracefile): Add declaration. * tracepoint.c (_initialize_tracepoint): Add declaration. * tui/tui-hooks.c (_initialize_tui_hooks): Add declaration. * tui/tui-interp.c (_initialize_tui_interp): Add declaration. * tui/tui-layout.c (_initialize_tui_layout): Add declaration. * tui/tui-regs.c (_initialize_tui_regs): Add declaration. * tui/tui-stack.c (_initialize_tui_stack): Add declaration. * tui/tui-win.c (_initialize_tui_win): Add declaration. * tui/tui.c (_initialize_tui): Add declaration. * typeprint.c (_initialize_typeprint): Add declaration. * ui-style.c (_initialize_ui_style): Add declaration. * unittests/array-view-selftests.c (_initialize_array_view_selftests): Add declaration. * unittests/child-path-selftests.c (_initialize_child_path_selftests): Add declaration. * unittests/cli-utils-selftests.c (_initialize_cli_utils_selftests): Add declaration. * unittests/common-utils-selftests.c (_initialize_common_utils_selftests): Add declaration. * unittests/copy_bitwise-selftests.c (_initialize_copy_bitwise_utils_selftests): Add declaration. * unittests/environ-selftests.c (_initialize_environ_selftests): Add declaration. * unittests/filtered_iterator-selftests.c (_initialize_filtered_iterator_selftests): Add declaration. * unittests/format_pieces-selftests.c (_initialize_format_pieces_selftests): Add declaration. * unittests/function-view-selftests.c (_initialize_function_view_selftests): Add declaration. * unittests/help-doc-selftests.c (_initialize_help_doc_selftests): Add declaration. * unittests/lookup_name_info-selftests.c (_initialize_lookup_name_info_selftests): Add declaration. * unittests/main-thread-selftests.c (_initialize_main_thread_selftests): Add declaration. * unittests/memory-map-selftests.c (_initialize_memory_map_selftests): Add declaration. * unittests/memrange-selftests.c (_initialize_memrange_selftests): Add declaration. * unittests/mkdir-recursive-selftests.c (_initialize_mkdir_recursive_selftests): Add declaration. * unittests/observable-selftests.c (_initialize_observer_selftest): Add declaration. * unittests/offset-type-selftests.c (_initialize_offset_type_selftests): Add declaration. * unittests/optional-selftests.c (_initialize_optional_selftests): Add declaration. * unittests/parse-connection-spec-selftests.c (_initialize_parse_connection_spec_selftests): Add declaration. * unittests/rsp-low-selftests.c (_initialize_rsp_low_selftests): Add declaration. * unittests/scoped_fd-selftests.c (_initialize_scoped_fd_selftests): Add declaration. * unittests/scoped_mmap-selftests.c (_initialize_scoped_mmap_selftests): Add declaration. * unittests/scoped_restore-selftests.c (_initialize_scoped_restore_selftests): Add declaration. * unittests/string_view-selftests.c (_initialize_string_view_selftests): Add declaration. * unittests/style-selftests.c (_initialize_style_selftest): Add declaration. * unittests/tracepoint-selftests.c (_initialize_tracepoint_selftests): Add declaration. * unittests/tui-selftests.c (_initialize_tui_selftest): Add declaration. * unittests/unpack-selftests.c (_initialize_unpack_selftests): Add declaration. * unittests/utils-selftests.c (_initialize_utils_selftests): Add declaration. * unittests/vec-utils-selftests.c (_initialize_vec_utils_selftests): Add declaration. * unittests/xml-utils-selftests.c (_initialize_xml_utils): Add declaration. * user-regs.c (_initialize_user_regs): Add declaration. * utils.c (_initialize_utils): Add declaration. * v850-tdep.c (_initialize_v850_tdep): Add declaration. * valops.c (_initialize_valops): Add declaration. * valprint.c (_initialize_valprint): Add declaration. * value.c (_initialize_values): Add declaration. * varobj.c (_initialize_varobj): Add declaration. * vax-bsd-nat.c (_initialize_vaxbsd_nat): Add declaration. * vax-nbsd-tdep.c (_initialize_vaxnbsd_tdep): Add declaration. * vax-tdep.c (_initialize_vax_tdep): Add declaration. * windows-nat.c (_initialize_windows_nat): Add declaration. (_initialize_check_for_gdb_ini): Add declaration. (_initialize_loadable): Add declaration. * windows-tdep.c (_initialize_windows_tdep): Add declaration. * x86-bsd-nat.c (_initialize_x86_bsd_nat): Add declaration. * x86-linux-nat.c (_initialize_x86_linux_nat): Add declaration. * xcoffread.c (_initialize_xcoffread): Add declaration. * xml-support.c (_initialize_xml_support): Add declaration. * xstormy16-tdep.c (_initialize_xstormy16_tdep): Add declaration. * xtensa-linux-nat.c (_initialize_xtensa_linux_nat): Add declaration. * xtensa-linux-tdep.c (_initialize_xtensa_linux_tdep): Add declaration. * xtensa-tdep.c (_initialize_xtensa_tdep): Add declaration. Change-Id: I13eec7e0ed2b3c427377a7bdb055cf46da64def9
2020-01-13 20:01:38 +01:00
void _initialize_ada_exp ();
void
gdb: add back declarations for _initialize functions I'd like to enable the -Wmissing-declarations warning. However, it warns for every _initialize function, for example: CXX dcache.o /home/smarchi/src/binutils-gdb/gdb/dcache.c: In function ‘void _initialize_dcache()’: /home/smarchi/src/binutils-gdb/gdb/dcache.c:688:1: error: no previous declaration for ‘void _initialize_dcache()’ [-Werror=missing-declarations] _initialize_dcache (void) ^~~~~~~~~~~~~~~~~~ The only practical way forward I found is to add back the declarations, which were removed by this commit: commit 481695ed5f6e0a8a9c9c50bfac1cdd2b3151e6c9 Author: John Baldwin <jhb@FreeBSD.org> Date: Sat Sep 9 11:02:37 2017 -0700 Remove unnecessary function prototypes. I don't think it's a big problem to have the declarations for these functions, but if anybody has a better solution for this, I'll be happy to use it. gdb/ChangeLog: * aarch64-fbsd-nat.c (_initialize_aarch64_fbsd_nat): Add declaration. * aarch64-fbsd-tdep.c (_initialize_aarch64_fbsd_tdep): Add declaration. * aarch64-linux-nat.c (_initialize_aarch64_linux_nat): Add declaration. * aarch64-linux-tdep.c (_initialize_aarch64_linux_tdep): Add declaration. * aarch64-newlib-tdep.c (_initialize_aarch64_newlib_tdep): Add declaration. * aarch64-tdep.c (_initialize_aarch64_tdep): Add declaration. * ada-exp.y (_initialize_ada_exp): Add declaration. * ada-lang.c (_initialize_ada_language): Add declaration. * ada-tasks.c (_initialize_tasks): Add declaration. * agent.c (_initialize_agent): Add declaration. * aix-thread.c (_initialize_aix_thread): Add declaration. * alpha-bsd-nat.c (_initialize_alphabsd_nat): Add declaration. * alpha-linux-nat.c (_initialize_alpha_linux_nat): Add declaration. * alpha-linux-tdep.c (_initialize_alpha_linux_tdep): Add declaration. * alpha-nbsd-tdep.c (_initialize_alphanbsd_tdep): Add declaration. * alpha-obsd-tdep.c (_initialize_alphaobsd_tdep): Add declaration. * alpha-tdep.c (_initialize_alpha_tdep): Add declaration. * amd64-darwin-tdep.c (_initialize_amd64_darwin_tdep): Add declaration. * amd64-dicos-tdep.c (_initialize_amd64_dicos_tdep): Add declaration. * amd64-fbsd-nat.c (_initialize_amd64fbsd_nat): Add declaration. * amd64-fbsd-tdep.c (_initialize_amd64fbsd_tdep): Add declaration. * amd64-linux-nat.c (_initialize_amd64_linux_nat): Add declaration. * amd64-linux-tdep.c (_initialize_amd64_linux_tdep): Add declaration. * amd64-nbsd-nat.c (_initialize_amd64nbsd_nat): Add declaration. * amd64-nbsd-tdep.c (_initialize_amd64nbsd_tdep): Add declaration. * amd64-obsd-nat.c (_initialize_amd64obsd_nat): Add declaration. * amd64-obsd-tdep.c (_initialize_amd64obsd_tdep): Add declaration. * amd64-sol2-tdep.c (_initialize_amd64_sol2_tdep): Add declaration. * amd64-tdep.c (_initialize_amd64_tdep): Add declaration. * amd64-windows-nat.c (_initialize_amd64_windows_nat): Add declaration. * amd64-windows-tdep.c (_initialize_amd64_windows_tdep): Add declaration. * annotate.c (_initialize_annotate): Add declaration. * arc-newlib-tdep.c (_initialize_arc_newlib_tdep): Add declaration. * arc-tdep.c (_initialize_arc_tdep): Add declaration. * arch-utils.c (_initialize_gdbarch_utils): Add declaration. * arm-fbsd-nat.c (_initialize_arm_fbsd_nat): Add declaration. * arm-fbsd-tdep.c (_initialize_arm_fbsd_tdep): Add declaration. * arm-linux-nat.c (_initialize_arm_linux_nat): Add declaration. * arm-linux-tdep.c (_initialize_arm_linux_tdep): Add declaration. * arm-nbsd-nat.c (_initialize_arm_netbsd_nat): Add declaration. * arm-nbsd-tdep.c (_initialize_arm_netbsd_tdep): Add declaration. * arm-obsd-tdep.c (_initialize_armobsd_tdep): Add declaration. * arm-pikeos-tdep.c (_initialize_arm_pikeos_tdep): Add declaration. * arm-symbian-tdep.c (_initialize_arm_symbian_tdep): Add declaration. * arm-tdep.c (_initialize_arm_tdep): Add declaration. * arm-wince-tdep.c (_initialize_arm_wince_tdep): Add declaration. * auto-load.c (_initialize_auto_load): Add declaration. * auxv.c (_initialize_auxv): Add declaration. * avr-tdep.c (_initialize_avr_tdep): Add declaration. * ax-gdb.c (_initialize_ax_gdb): Add declaration. * bfin-linux-tdep.c (_initialize_bfin_linux_tdep): Add declaration. * bfin-tdep.c (_initialize_bfin_tdep): Add declaration. * break-catch-sig.c (_initialize_break_catch_sig): Add declaration. * break-catch-syscall.c (_initialize_break_catch_syscall): Add declaration. * break-catch-throw.c (_initialize_break_catch_throw): Add declaration. * breakpoint.c (_initialize_breakpoint): Add declaration. * bsd-uthread.c (_initialize_bsd_uthread): Add declaration. * btrace.c (_initialize_btrace): Add declaration. * charset.c (_initialize_charset): Add declaration. * cli/cli-cmds.c (_initialize_cli_cmds): Add declaration. * cli/cli-dump.c (_initialize_cli_dump): Add declaration. * cli/cli-interp.c (_initialize_cli_interp): Add declaration. * cli/cli-logging.c (_initialize_cli_logging): Add declaration. * cli/cli-script.c (_initialize_cli_script): Add declaration. * cli/cli-style.c (_initialize_cli_style): Add declaration. * coff-pe-read.c (_initialize_coff_pe_read): Add declaration. * coffread.c (_initialize_coffread): Add declaration. * compile/compile-cplus-types.c (_initialize_compile_cplus_types): Add declaration. * compile/compile.c (_initialize_compile): Add declaration. * complaints.c (_initialize_complaints): Add declaration. * completer.c (_initialize_completer): Add declaration. * copying.c (_initialize_copying): Add declaration. * corefile.c (_initialize_core): Add declaration. * corelow.c (_initialize_corelow): Add declaration. * cp-abi.c (_initialize_cp_abi): Add declaration. * cp-namespace.c (_initialize_cp_namespace): Add declaration. * cp-support.c (_initialize_cp_support): Add declaration. * cp-valprint.c (_initialize_cp_valprint): Add declaration. * cris-linux-tdep.c (_initialize_cris_linux_tdep): Add declaration. * cris-tdep.c (_initialize_cris_tdep): Add declaration. * csky-linux-tdep.c (_initialize_csky_linux_tdep): Add declaration. * csky-tdep.c (_initialize_csky_tdep): Add declaration. * ctfread.c (_initialize_ctfread): Add declaration. * d-lang.c (_initialize_d_language): Add declaration. * darwin-nat-info.c (_initialize_darwin_info_commands): Add declaration. * darwin-nat.c (_initialize_darwin_nat): Add declaration. * dbxread.c (_initialize_dbxread): Add declaration. * dcache.c (_initialize_dcache): Add declaration. * disasm-selftests.c (_initialize_disasm_selftests): Add declaration. * disasm.c (_initialize_disasm): Add declaration. * dtrace-probe.c (_initialize_dtrace_probe): Add declaration. * dummy-frame.c (_initialize_dummy_frame): Add declaration. * dwarf-index-cache.c (_initialize_index_cache): Add declaration. * dwarf-index-write.c (_initialize_dwarf_index_write): Add declaration. * dwarf2-frame-tailcall.c (_initialize_tailcall_frame): Add declaration. * dwarf2-frame.c (_initialize_dwarf2_frame): Add declaration. * dwarf2expr.c (_initialize_dwarf2expr): Add declaration. * dwarf2loc.c (_initialize_dwarf2loc): Add declaration. * dwarf2read.c (_initialize_dwarf2_read): Add declaration. * elfread.c (_initialize_elfread): Add declaration. * exec.c (_initialize_exec): Add declaration. * extension.c (_initialize_extension): Add declaration. * f-lang.c (_initialize_f_language): Add declaration. * f-valprint.c (_initialize_f_valprint): Add declaration. * fbsd-nat.c (_initialize_fbsd_nat): Add declaration. * fbsd-tdep.c (_initialize_fbsd_tdep): Add declaration. * filesystem.c (_initialize_filesystem): Add declaration. * findcmd.c (_initialize_mem_search): Add declaration. * findvar.c (_initialize_findvar): Add declaration. * fork-child.c (_initialize_fork_child): Add declaration. * frame-base.c (_initialize_frame_base): Add declaration. * frame-unwind.c (_initialize_frame_unwind): Add declaration. * frame.c (_initialize_frame): Add declaration. * frv-linux-tdep.c (_initialize_frv_linux_tdep): Add declaration. * frv-tdep.c (_initialize_frv_tdep): Add declaration. * ft32-tdep.c (_initialize_ft32_tdep): Add declaration. * gcore.c (_initialize_gcore): Add declaration. * gdb-demangle.c (_initialize_gdb_demangle): Add declaration. * gdb_bfd.c (_initialize_gdb_bfd): Add declaration. * gdbarch-selftests.c (_initialize_gdbarch_selftests): Add declaration. * gdbarch.c (_initialize_gdbarch): Add declaration. * gdbtypes.c (_initialize_gdbtypes): Add declaration. * gnu-nat.c (_initialize_gnu_nat): Add declaration. * gnu-v2-abi.c (_initialize_gnu_v2_abi): Add declaration. * gnu-v3-abi.c (_initialize_gnu_v3_abi): Add declaration. * go-lang.c (_initialize_go_language): Add declaration. * go32-nat.c (_initialize_go32_nat): Add declaration. * guile/guile.c (_initialize_guile): Add declaration. * h8300-tdep.c (_initialize_h8300_tdep): Add declaration. * hppa-linux-nat.c (_initialize_hppa_linux_nat): Add declaration. * hppa-linux-tdep.c (_initialize_hppa_linux_tdep): Add declaration. * hppa-nbsd-nat.c (_initialize_hppanbsd_nat): Add declaration. * hppa-nbsd-tdep.c (_initialize_hppanbsd_tdep): Add declaration. * hppa-obsd-nat.c (_initialize_hppaobsd_nat): Add declaration. * hppa-obsd-tdep.c (_initialize_hppabsd_tdep): Add declaration. * hppa-tdep.c (_initialize_hppa_tdep): Add declaration. * i386-bsd-nat.c (_initialize_i386bsd_nat): Add declaration. * i386-cygwin-tdep.c (_initialize_i386_cygwin_tdep): Add declaration. * i386-darwin-nat.c (_initialize_i386_darwin_nat): Add declaration. * i386-darwin-tdep.c (_initialize_i386_darwin_tdep): Add declaration. * i386-dicos-tdep.c (_initialize_i386_dicos_tdep): Add declaration. * i386-fbsd-nat.c (_initialize_i386fbsd_nat): Add declaration. * i386-fbsd-tdep.c (_initialize_i386fbsd_tdep): Add declaration. * i386-gnu-nat.c (_initialize_i386gnu_nat): Add declaration. * i386-gnu-tdep.c (_initialize_i386gnu_tdep): Add declaration. * i386-go32-tdep.c (_initialize_i386_go32_tdep): Add declaration. * i386-linux-nat.c (_initialize_i386_linux_nat): Add declaration. * i386-linux-tdep.c (_initialize_i386_linux_tdep): Add declaration. * i386-nbsd-nat.c (_initialize_i386nbsd_nat): Add declaration. * i386-nbsd-tdep.c (_initialize_i386nbsd_tdep): Add declaration. * i386-nto-tdep.c (_initialize_i386nto_tdep): Add declaration. * i386-obsd-nat.c (_initialize_i386obsd_nat): Add declaration. * i386-obsd-tdep.c (_initialize_i386obsd_tdep): Add declaration. * i386-sol2-nat.c (_initialize_amd64_sol2_nat): Add declaration. * i386-sol2-tdep.c (_initialize_i386_sol2_tdep): Add declaration. * i386-tdep.c (_initialize_i386_tdep): Add declaration. * i386-windows-nat.c (_initialize_i386_windows_nat): Add declaration. * ia64-libunwind-tdep.c (_initialize_libunwind_frame): Add declaration. * ia64-linux-nat.c (_initialize_ia64_linux_nat): Add declaration. * ia64-linux-tdep.c (_initialize_ia64_linux_tdep): Add declaration. * ia64-tdep.c (_initialize_ia64_tdep): Add declaration. * ia64-vms-tdep.c (_initialize_ia64_vms_tdep): Add declaration. * infcall.c (_initialize_infcall): Add declaration. * infcmd.c (_initialize_infcmd): Add declaration. * inflow.c (_initialize_inflow): Add declaration. * infrun.c (_initialize_infrun): Add declaration. * interps.c (_initialize_interpreter): Add declaration. * iq2000-tdep.c (_initialize_iq2000_tdep): Add declaration. * jit.c (_initialize_jit): Add declaration. * language.c (_initialize_language): Add declaration. * linux-fork.c (_initialize_linux_fork): Add declaration. * linux-nat.c (_initialize_linux_nat): Add declaration. * linux-tdep.c (_initialize_linux_tdep): Add declaration. * linux-thread-db.c (_initialize_thread_db): Add declaration. * lm32-tdep.c (_initialize_lm32_tdep): Add declaration. * m2-lang.c (_initialize_m2_language): Add declaration. * m32c-tdep.c (_initialize_m32c_tdep): Add declaration. * m32r-linux-nat.c (_initialize_m32r_linux_nat): Add declaration. * m32r-linux-tdep.c (_initialize_m32r_linux_tdep): Add declaration. * m32r-tdep.c (_initialize_m32r_tdep): Add declaration. * m68hc11-tdep.c (_initialize_m68hc11_tdep): Add declaration. * m68k-bsd-nat.c (_initialize_m68kbsd_nat): Add declaration. * m68k-bsd-tdep.c (_initialize_m68kbsd_tdep): Add declaration. * m68k-linux-nat.c (_initialize_m68k_linux_nat): Add declaration. * m68k-linux-tdep.c (_initialize_m68k_linux_tdep): Add declaration. * m68k-tdep.c (_initialize_m68k_tdep): Add declaration. * machoread.c (_initialize_machoread): Add declaration. * macrocmd.c (_initialize_macrocmd): Add declaration. * macroscope.c (_initialize_macroscope): Add declaration. * maint-test-options.c (_initialize_maint_test_options): Add declaration. * maint-test-settings.c (_initialize_maint_test_settings): Add declaration. * maint.c (_initialize_maint_cmds): Add declaration. * mdebugread.c (_initialize_mdebugread): Add declaration. * memattr.c (_initialize_mem): Add declaration. * mep-tdep.c (_initialize_mep_tdep): Add declaration. * mi/mi-cmd-env.c (_initialize_mi_cmd_env): Add declaration. * mi/mi-cmds.c (_initialize_mi_cmds): Add declaration. * mi/mi-interp.c (_initialize_mi_interp): Add declaration. * mi/mi-main.c (_initialize_mi_main): Add declaration. * microblaze-linux-tdep.c (_initialize_microblaze_linux_tdep): Add declaration. * microblaze-tdep.c (_initialize_microblaze_tdep): Add declaration. * mips-fbsd-nat.c (_initialize_mips_fbsd_nat): Add declaration. * mips-fbsd-tdep.c (_initialize_mips_fbsd_tdep): Add declaration. * mips-linux-nat.c (_initialize_mips_linux_nat): Add declaration. * mips-linux-tdep.c (_initialize_mips_linux_tdep): Add declaration. * mips-nbsd-nat.c (_initialize_mipsnbsd_nat): Add declaration. * mips-nbsd-tdep.c (_initialize_mipsnbsd_tdep): Add declaration. * mips-sde-tdep.c (_initialize_mips_sde_tdep): Add declaration. * mips-tdep.c (_initialize_mips_tdep): Add declaration. * mips64-obsd-nat.c (_initialize_mips64obsd_nat): Add declaration. * mips64-obsd-tdep.c (_initialize_mips64obsd_tdep): Add declaration. * mipsread.c (_initialize_mipsread): Add declaration. * mn10300-linux-tdep.c (_initialize_mn10300_linux_tdep): Add declaration. * mn10300-tdep.c (_initialize_mn10300_tdep): Add declaration. * moxie-tdep.c (_initialize_moxie_tdep): Add declaration. * msp430-tdep.c (_initialize_msp430_tdep): Add declaration. * nds32-tdep.c (_initialize_nds32_tdep): Add declaration. * nios2-linux-tdep.c (_initialize_nios2_linux_tdep): Add declaration. * nios2-tdep.c (_initialize_nios2_tdep): Add declaration. * nto-procfs.c (_initialize_procfs): Add declaration. * objc-lang.c (_initialize_objc_language): Add declaration. * observable.c (_initialize_observer): Add declaration. * opencl-lang.c (_initialize_opencl_language): Add declaration. * or1k-linux-tdep.c (_initialize_or1k_linux_tdep): Add declaration. * or1k-tdep.c (_initialize_or1k_tdep): Add declaration. * osabi.c (_initialize_gdb_osabi): Add declaration. * osdata.c (_initialize_osdata): Add declaration. * p-valprint.c (_initialize_pascal_valprint): Add declaration. * parse.c (_initialize_parse): Add declaration. * ppc-fbsd-nat.c (_initialize_ppcfbsd_nat): Add declaration. * ppc-fbsd-tdep.c (_initialize_ppcfbsd_tdep): Add declaration. * ppc-linux-nat.c (_initialize_ppc_linux_nat): Add declaration. * ppc-linux-tdep.c (_initialize_ppc_linux_tdep): Add declaration. * ppc-nbsd-nat.c (_initialize_ppcnbsd_nat): Add declaration. * ppc-nbsd-tdep.c (_initialize_ppcnbsd_tdep): Add declaration. * ppc-obsd-nat.c (_initialize_ppcobsd_nat): Add declaration. * ppc-obsd-tdep.c (_initialize_ppcobsd_tdep): Add declaration. * printcmd.c (_initialize_printcmd): Add declaration. * probe.c (_initialize_probe): Add declaration. * proc-api.c (_initialize_proc_api): Add declaration. * proc-events.c (_initialize_proc_events): Add declaration. * proc-service.c (_initialize_proc_service): Add declaration. * procfs.c (_initialize_procfs): Add declaration. * producer.c (_initialize_producer): Add declaration. * psymtab.c (_initialize_psymtab): Add declaration. * python/python.c (_initialize_python): Add declaration. * ravenscar-thread.c (_initialize_ravenscar): Add declaration. * record-btrace.c (_initialize_record_btrace): Add declaration. * record-full.c (_initialize_record_full): Add declaration. * record.c (_initialize_record): Add declaration. * regcache-dump.c (_initialize_regcache_dump): Add declaration. * regcache.c (_initialize_regcache): Add declaration. * reggroups.c (_initialize_reggroup): Add declaration. * remote-notif.c (_initialize_notif): Add declaration. * remote-sim.c (_initialize_remote_sim): Add declaration. * remote.c (_initialize_remote): Add declaration. * reverse.c (_initialize_reverse): Add declaration. * riscv-fbsd-nat.c (_initialize_riscv_fbsd_nat): Add declaration. * riscv-fbsd-tdep.c (_initialize_riscv_fbsd_tdep): Add declaration. * riscv-linux-nat.c (_initialize_riscv_linux_nat): Add declaration. * riscv-linux-tdep.c (_initialize_riscv_linux_tdep): Add declaration. * riscv-tdep.c (_initialize_riscv_tdep): Add declaration. * rl78-tdep.c (_initialize_rl78_tdep): Add declaration. * rs6000-aix-tdep.c (_initialize_rs6000_aix_tdep): Add declaration. * rs6000-lynx178-tdep.c (_initialize_rs6000_lynx178_tdep): Add declaration. * rs6000-nat.c (_initialize_rs6000_nat): Add declaration. * rs6000-tdep.c (_initialize_rs6000_tdep): Add declaration. * run-on-main-thread.c (_initialize_run_on_main_thread): Add declaration. * rust-exp.y (_initialize_rust_exp): Add declaration. * rx-tdep.c (_initialize_rx_tdep): Add declaration. * s12z-tdep.c (_initialize_s12z_tdep): Add declaration. * s390-linux-nat.c (_initialize_s390_nat): Add declaration. * s390-linux-tdep.c (_initialize_s390_linux_tdep): Add declaration. * s390-tdep.c (_initialize_s390_tdep): Add declaration. * score-tdep.c (_initialize_score_tdep): Add declaration. * ser-go32.c (_initialize_ser_dos): Add declaration. * ser-mingw.c (_initialize_ser_windows): Add declaration. * ser-pipe.c (_initialize_ser_pipe): Add declaration. * ser-tcp.c (_initialize_ser_tcp): Add declaration. * ser-uds.c (_initialize_ser_socket): Add declaration. * ser-unix.c (_initialize_ser_hardwire): Add declaration. * serial.c (_initialize_serial): Add declaration. * sh-linux-tdep.c (_initialize_sh_linux_tdep): Add declaration. * sh-nbsd-nat.c (_initialize_shnbsd_nat): Add declaration. * sh-nbsd-tdep.c (_initialize_shnbsd_tdep): Add declaration. * sh-tdep.c (_initialize_sh_tdep): Add declaration. * skip.c (_initialize_step_skip): Add declaration. * sol-thread.c (_initialize_sol_thread): Add declaration. * solib-aix.c (_initialize_solib_aix): Add declaration. * solib-darwin.c (_initialize_darwin_solib): Add declaration. * solib-dsbt.c (_initialize_dsbt_solib): Add declaration. * solib-frv.c (_initialize_frv_solib): Add declaration. * solib-svr4.c (_initialize_svr4_solib): Add declaration. * solib-target.c (_initialize_solib_target): Add declaration. * solib.c (_initialize_solib): Add declaration. * source-cache.c (_initialize_source_cache): Add declaration. * source.c (_initialize_source): Add declaration. * sparc-linux-nat.c (_initialize_sparc_linux_nat): Add declaration. * sparc-linux-tdep.c (_initialize_sparc_linux_tdep): Add declaration. * sparc-nat.c (_initialize_sparc_nat): Add declaration. * sparc-nbsd-nat.c (_initialize_sparcnbsd_nat): Add declaration. * sparc-nbsd-tdep.c (_initialize_sparcnbsd_tdep): Add declaration. * sparc-obsd-tdep.c (_initialize_sparc32obsd_tdep): Add declaration. * sparc-sol2-tdep.c (_initialize_sparc_sol2_tdep): Add declaration. * sparc-tdep.c (_initialize_sparc_tdep): Add declaration. * sparc64-fbsd-nat.c (_initialize_sparc64fbsd_nat): Add declaration. * sparc64-fbsd-tdep.c (_initialize_sparc64fbsd_tdep): Add declaration. * sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Add declaration. * sparc64-linux-tdep.c (_initialize_sparc64_linux_tdep): Add declaration. * sparc64-nat.c (_initialize_sparc64_nat): Add declaration. * sparc64-nbsd-nat.c (_initialize_sparc64nbsd_nat): Add declaration. * sparc64-nbsd-tdep.c (_initialize_sparc64nbsd_tdep): Add declaration. * sparc64-obsd-nat.c (_initialize_sparc64obsd_nat): Add declaration. * sparc64-obsd-tdep.c (_initialize_sparc64obsd_tdep): Add declaration. * sparc64-sol2-tdep.c (_initialize_sparc64_sol2_tdep): Add declaration. * sparc64-tdep.c (_initialize_sparc64_adi_tdep): Add declaration. * stabsread.c (_initialize_stabsread): Add declaration. * stack.c (_initialize_stack): Add declaration. * stap-probe.c (_initialize_stap_probe): Add declaration. * std-regs.c (_initialize_frame_reg): Add declaration. * symfile-debug.c (_initialize_symfile_debug): Add declaration. * symfile-mem.c (_initialize_symfile_mem): Add declaration. * symfile.c (_initialize_symfile): Add declaration. * symmisc.c (_initialize_symmisc): Add declaration. * symtab.c (_initialize_symtab): Add declaration. * target.c (_initialize_target): Add declaration. * target-connection.c (_initialize_target_connection): Add declaration. * target-dcache.c (_initialize_target_dcache): Add declaration. * target-descriptions.c (_initialize_target_descriptions): Add declaration. * thread.c (_initialize_thread): Add declaration. * tic6x-linux-tdep.c (_initialize_tic6x_linux_tdep): Add declaration. * tic6x-tdep.c (_initialize_tic6x_tdep): Add declaration. * tilegx-linux-nat.c (_initialize_tile_linux_nat): Add declaration. * tilegx-linux-tdep.c (_initialize_tilegx_linux_tdep): Add declaration. * tilegx-tdep.c (_initialize_tilegx_tdep): Add declaration. * tracectf.c (_initialize_ctf): Add declaration. * tracefile-tfile.c (_initialize_tracefile_tfile): Add declaration. * tracefile.c (_initialize_tracefile): Add declaration. * tracepoint.c (_initialize_tracepoint): Add declaration. * tui/tui-hooks.c (_initialize_tui_hooks): Add declaration. * tui/tui-interp.c (_initialize_tui_interp): Add declaration. * tui/tui-layout.c (_initialize_tui_layout): Add declaration. * tui/tui-regs.c (_initialize_tui_regs): Add declaration. * tui/tui-stack.c (_initialize_tui_stack): Add declaration. * tui/tui-win.c (_initialize_tui_win): Add declaration. * tui/tui.c (_initialize_tui): Add declaration. * typeprint.c (_initialize_typeprint): Add declaration. * ui-style.c (_initialize_ui_style): Add declaration. * unittests/array-view-selftests.c (_initialize_array_view_selftests): Add declaration. * unittests/child-path-selftests.c (_initialize_child_path_selftests): Add declaration. * unittests/cli-utils-selftests.c (_initialize_cli_utils_selftests): Add declaration. * unittests/common-utils-selftests.c (_initialize_common_utils_selftests): Add declaration. * unittests/copy_bitwise-selftests.c (_initialize_copy_bitwise_utils_selftests): Add declaration. * unittests/environ-selftests.c (_initialize_environ_selftests): Add declaration. * unittests/filtered_iterator-selftests.c (_initialize_filtered_iterator_selftests): Add declaration. * unittests/format_pieces-selftests.c (_initialize_format_pieces_selftests): Add declaration. * unittests/function-view-selftests.c (_initialize_function_view_selftests): Add declaration. * unittests/help-doc-selftests.c (_initialize_help_doc_selftests): Add declaration. * unittests/lookup_name_info-selftests.c (_initialize_lookup_name_info_selftests): Add declaration. * unittests/main-thread-selftests.c (_initialize_main_thread_selftests): Add declaration. * unittests/memory-map-selftests.c (_initialize_memory_map_selftests): Add declaration. * unittests/memrange-selftests.c (_initialize_memrange_selftests): Add declaration. * unittests/mkdir-recursive-selftests.c (_initialize_mkdir_recursive_selftests): Add declaration. * unittests/observable-selftests.c (_initialize_observer_selftest): Add declaration. * unittests/offset-type-selftests.c (_initialize_offset_type_selftests): Add declaration. * unittests/optional-selftests.c (_initialize_optional_selftests): Add declaration. * unittests/parse-connection-spec-selftests.c (_initialize_parse_connection_spec_selftests): Add declaration. * unittests/rsp-low-selftests.c (_initialize_rsp_low_selftests): Add declaration. * unittests/scoped_fd-selftests.c (_initialize_scoped_fd_selftests): Add declaration. * unittests/scoped_mmap-selftests.c (_initialize_scoped_mmap_selftests): Add declaration. * unittests/scoped_restore-selftests.c (_initialize_scoped_restore_selftests): Add declaration. * unittests/string_view-selftests.c (_initialize_string_view_selftests): Add declaration. * unittests/style-selftests.c (_initialize_style_selftest): Add declaration. * unittests/tracepoint-selftests.c (_initialize_tracepoint_selftests): Add declaration. * unittests/tui-selftests.c (_initialize_tui_selftest): Add declaration. * unittests/unpack-selftests.c (_initialize_unpack_selftests): Add declaration. * unittests/utils-selftests.c (_initialize_utils_selftests): Add declaration. * unittests/vec-utils-selftests.c (_initialize_vec_utils_selftests): Add declaration. * unittests/xml-utils-selftests.c (_initialize_xml_utils): Add declaration. * user-regs.c (_initialize_user_regs): Add declaration. * utils.c (_initialize_utils): Add declaration. * v850-tdep.c (_initialize_v850_tdep): Add declaration. * valops.c (_initialize_valops): Add declaration. * valprint.c (_initialize_valprint): Add declaration. * value.c (_initialize_values): Add declaration. * varobj.c (_initialize_varobj): Add declaration. * vax-bsd-nat.c (_initialize_vaxbsd_nat): Add declaration. * vax-nbsd-tdep.c (_initialize_vaxnbsd_tdep): Add declaration. * vax-tdep.c (_initialize_vax_tdep): Add declaration. * windows-nat.c (_initialize_windows_nat): Add declaration. (_initialize_check_for_gdb_ini): Add declaration. (_initialize_loadable): Add declaration. * windows-tdep.c (_initialize_windows_tdep): Add declaration. * x86-bsd-nat.c (_initialize_x86_bsd_nat): Add declaration. * x86-linux-nat.c (_initialize_x86_linux_nat): Add declaration. * xcoffread.c (_initialize_xcoffread): Add declaration. * xml-support.c (_initialize_xml_support): Add declaration. * xstormy16-tdep.c (_initialize_xstormy16_tdep): Add declaration. * xtensa-linux-nat.c (_initialize_xtensa_linux_nat): Add declaration. * xtensa-linux-tdep.c (_initialize_xtensa_linux_tdep): Add declaration. * xtensa-tdep.c (_initialize_xtensa_tdep): Add declaration. Change-Id: I13eec7e0ed2b3c427377a7bdb055cf46da64def9
2020-01-13 20:01:38 +01:00
_initialize_ada_exp ()
{
obstack_init (&temp_parse_space);
}