binutils-gdb/gdb/go-exp.y

1584 lines
40 KiB
Plaintext
Raw Normal View History

Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
/* YACC parser for Go expressions, for GDB.
Copyright (C) 2012-2020 Free Software Foundation, Inc.
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
This file is part of GDB.
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.
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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* This file is derived from c-exp.y, p-exp.y. */
/* Parse a Go 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.
Note that 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. */
/* Known bugs or limitations:
- Unicode
- &^
- '_' (blank identifier)
- automatic deref of pointers
- method expressions
- interfaces, channels, etc.
And lots of other things.
I'm sure there's some cleanup to do.
*/
%{
#include "defs.h"
#include <ctype.h>
#include "expression.h"
#include "value.h"
#include "parser-defs.h"
#include "language.h"
#include "c-lang.h"
#include "go-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 "charset.h"
#include "block.h"
#define parse_type(ps) builtin_type (ps->gdbarch ())
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
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 go_
#include "yy-remap.h"
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07: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
/* The state of the parser, used internally when we are parsing the
expression. */
static struct parser_state *pstate = NULL;
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +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 *);
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
%}
/* Although the yacc "value" of an expression is not used,
since the result is stored in the structure being created,
other node types do have values. */
%union
{
LONGEST lval;
struct {
LONGEST val;
struct type *type;
} typed_val_int;
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];
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
struct type *type;
} typed_val_float;
struct stoken sval;
struct symtoken ssym;
struct type *tval;
struct typed_stoken tsval;
struct ttype tsym;
int voidval;
enum exp_opcode opcode;
struct internalvar *ivar;
struct stoken_vector svec;
}
%{
/* YYSTYPE gets defined by %union. */
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 int parse_number (struct parser_state *,
const char *, int, int, YYSTYPE *);
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
%}
%type <voidval> exp exp1 type_exp start variable lcurly
%type <lval> rcurly
%type <tval> type
%token <typed_val_int> INT
%token <typed_val_float> FLOAT
/* Both NAME and TYPENAME tokens represent symbols in the input,
and both convey their data as strings.
But a TYPENAME is a string that happens to be defined as a type
or builtin type name (such as int or char)
and a NAME is any other symbol.
Contexts where this distinction is not important can use the
nonterminal "name", which matches either NAME or TYPENAME. */
%token <tsval> RAW_STRING
%token <tsval> STRING
%token <tsval> CHAR
%token <ssym> NAME
%token <tsym> TYPENAME /* Not TYPE_NAME cus already taken. */
%token <voidval> COMPLETE
/*%type <sval> name*/
%type <svec> string_exp
%type <ssym> name_not_typename
/* A NAME_OR_INT is a symbol which is not known in the symbol table,
but which would parse as a valid number in the current input radix.
E.g. "c" when input_radix==16. Depending on the parse, it will be
turned into a name or into a number. */
%token <ssym> NAME_OR_INT
%token <lval> TRUE_KEYWORD FALSE_KEYWORD
%token STRUCT_KEYWORD INTERFACE_KEYWORD TYPE_KEYWORD CHAN_KEYWORD
%token SIZEOF_KEYWORD
%token LEN_KEYWORD CAP_KEYWORD
%token NEW_KEYWORD
%token IOTA_KEYWORD NIL_KEYWORD
%token CONST_KEYWORD
%token DOTDOTDOT
%token ENTRY
%token ERROR
/* Special type cases. */
%token BYTE_KEYWORD /* An alias of uint8. */
%token <sval> DOLLAR_VARIABLE
%token <opcode> ASSIGN_MODIFY
%left ','
%left ABOVE_COMMA
%right '=' ASSIGN_MODIFY
%right '?'
%left OROR
%left ANDAND
%left '|'
%left '^'
%left '&'
%left ANDNOT
%left EQUAL NOTEQUAL
%left '<' '>' LEQ GEQ
%left LSH RSH
%left '@'
%left '+' '-'
%left '*' '/' '%'
%right UNARY INCREMENT DECREMENT
%right LEFT_ARROW '.' '[' '('
%%
start : exp1
| type_exp
;
type_exp: 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); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
/* Expressions, including the comma 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); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
/* Expressions, not including the comma operator. */
exp : '*' 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_IND); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
exp : '&' 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_ADDR); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
exp : '-' 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); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
exp : '+' 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); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
exp : '!' 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); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
exp : '^' 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_COMPLEMENT); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
exp : exp INCREMENT %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_POSTINCREMENT); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
exp : exp DECREMENT %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_POSTDECREMENT); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
/* foo->bar is not in Go. May want as a gdb extension. Later. */
exp : exp '.' name_not_typename
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, STRUCTOP_STRUCT);
write_exp_string (pstate, $3.stoken);
write_exp_elt_opcode (pstate, STRUCTOP_STRUCT); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
exp : exp '.' name_not_typename COMPLETE
Move completion parsing to parser_state This moves the globals and functions related to parsing for completion to parser_state. A new structure is introduced in order to return completion results from the parse back to parse_expression_for_completion. gdb/ChangeLog 2019-04-04 Tom Tromey <tom@tromey.com> * rust-exp.y (rust_parser::lex_identifier, rustyylex) (rust_parser::convert_ast_to_expression, rust_parse) (rust_lex_test_completion, rust_lex_tests): Update. * parser-defs.h (struct expr_completion_state): New. (struct parser_state) <parser_state>: Add completion parameter. <mark_struct_expression, mark_completion_tag>: New methods. <parse_completion, m_completion_state>: New members. (prefixify_expression, null_post_parser): Update. (mark_struct_expression, mark_completion_tag): Don't declare. * parse.c (parse_completion, expout_last_struct) (expout_tag_completion_type, expout_completion_name): Remove globals. (parser_state::mark_struct_expression) (parser_state::mark_completion_tag): Now methods. (prefixify_expression): Add last_struct parameter. (prefixify_subexp): Likewise. (parse_exp_1): Update. (parse_exp_in_context): Add cstate parameter. Update. (parse_expression_for_completion): Create an expr_completion_state. (null_post_parser): Add "completion" parameter. * p-exp.y: Update rules. (yylex): Update. * language.h (struct language_defn) <la_post_parser>: Add "completing" parameter. * go-exp.y: Update rules. (lex_one_token): Update. * expression.h (parse_completion): Don't declare. * d-exp.y: Update rules. (lex_one_token): Update rules. * c-exp.y: Update rules. (lex_one_token): Update. * ada-lang.c (resolve): Add "parse_completion" parameter. (resolve_subexp): Likewise. (ada_resolve_function): Likewise.
2019-03-25 05:50:14 +01:00
{ pstate->mark_struct_expression ();
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, STRUCTOP_STRUCT);
write_exp_string (pstate, $3.stoken);
write_exp_elt_opcode (pstate, STRUCTOP_STRUCT); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
exp : exp '.' COMPLETE
{ struct stoken s;
Move completion parsing to parser_state This moves the globals and functions related to parsing for completion to parser_state. A new structure is introduced in order to return completion results from the parse back to parse_expression_for_completion. gdb/ChangeLog 2019-04-04 Tom Tromey <tom@tromey.com> * rust-exp.y (rust_parser::lex_identifier, rustyylex) (rust_parser::convert_ast_to_expression, rust_parse) (rust_lex_test_completion, rust_lex_tests): Update. * parser-defs.h (struct expr_completion_state): New. (struct parser_state) <parser_state>: Add completion parameter. <mark_struct_expression, mark_completion_tag>: New methods. <parse_completion, m_completion_state>: New members. (prefixify_expression, null_post_parser): Update. (mark_struct_expression, mark_completion_tag): Don't declare. * parse.c (parse_completion, expout_last_struct) (expout_tag_completion_type, expout_completion_name): Remove globals. (parser_state::mark_struct_expression) (parser_state::mark_completion_tag): Now methods. (prefixify_expression): Add last_struct parameter. (prefixify_subexp): Likewise. (parse_exp_1): Update. (parse_exp_in_context): Add cstate parameter. Update. (parse_expression_for_completion): Create an expr_completion_state. (null_post_parser): Add "completion" parameter. * p-exp.y: Update rules. (yylex): Update. * language.h (struct language_defn) <la_post_parser>: Add "completing" parameter. * go-exp.y: Update rules. (lex_one_token): Update. * expression.h (parse_completion): Don't declare. * d-exp.y: Update rules. (lex_one_token): Update rules. * c-exp.y: Update rules. (lex_one_token): Update. * ada-lang.c (resolve): Add "parse_completion" parameter. (resolve_subexp): Likewise. (ada_resolve_function): Likewise.
2019-03-25 05:50:14 +01:00
pstate->mark_struct_expression ();
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, STRUCTOP_STRUCT);
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
s.ptr = "";
s.length = 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
write_exp_string (pstate, s);
write_exp_elt_opcode (pstate, STRUCTOP_STRUCT); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
exp : exp '[' exp1 ']'
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); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
exp : exp '('
/* This is to save the value of arglist_len
being accumulated by an outer function call. */
{ pstate->start_arglist (); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
arglist ')' %prec LEFT_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_FUNCALL);
write_exp_elt_longcst (pstate,
pstate->end_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, OP_FUNCALL); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
lcurly : '{'
{ pstate->start_arglist (); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
arglist :
;
arglist : exp
{ pstate->arglist_len = 1; }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
arglist : arglist ',' exp %prec ABOVE_COMMA
{ pstate->arglist_len++; }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
rcurly : '}'
{ $$ = pstate->end_arglist () - 1; }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
exp : lcurly type rcurly 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_MEMVAL);
write_exp_elt_type (pstate, $2);
write_exp_elt_opcode (pstate, UNOP_MEMVAL); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
exp : type '(' 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_CAST);
write_exp_elt_type (pstate, $1);
write_exp_elt_opcode (pstate, UNOP_CAST); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
exp : '(' exp1 ')'
{ }
;
/* Binary operators in order of decreasing precedence. */
exp : 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, BINOP_REPEAT); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
exp : 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, BINOP_MUL); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
exp : 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, BINOP_DIV); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
exp : 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, BINOP_REM); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
exp : 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, BINOP_ADD); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
exp : 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, BINOP_SUB); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
exp : exp LSH 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_LSH); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
exp : exp RSH 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_RSH); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
exp : exp EQUAL 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); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
exp : exp NOTEQUAL 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); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
exp : exp LEQ 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); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
exp : exp GEQ 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); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
exp : 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, BINOP_LESS); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
exp : 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, BINOP_GTR); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
exp : 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, BINOP_BITWISE_AND); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
exp : 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, BINOP_BITWISE_XOR); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
exp : 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, BINOP_BITWISE_IOR); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
exp : exp ANDAND 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_LOGICAL_AND); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
exp : exp OROR 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_LOGICAL_OR); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
exp : exp '?' exp ':' exp %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, TERNOP_COND); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
exp : 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, BINOP_ASSIGN); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
exp : exp ASSIGN_MODIFY 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_ASSIGN_MODIFY);
write_exp_elt_opcode (pstate, $2);
write_exp_elt_opcode (pstate, BINOP_ASSIGN_MODIFY); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
exp : 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_exp_elt_opcode (pstate, OP_LONG);
write_exp_elt_type (pstate, $1.type);
write_exp_elt_longcst (pstate, (LONGEST)($1.val));
write_exp_elt_opcode (pstate, OP_LONG); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
exp : CHAR
{
struct stoken_vector vec;
vec.len = 1;
vec.tokens = &$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_string_vector (pstate, $1.type, &vec);
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
}
;
exp : NAME_OR_INT
{ YYSTYPE val;
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
parse_number (pstate, $1.stoken.ptr,
$1.stoken.length, 0, &val);
write_exp_elt_opcode (pstate, OP_LONG);
write_exp_elt_type (pstate, val.typed_val_int.type);
write_exp_elt_longcst (pstate, (LONGEST)
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
val.typed_val_int.val);
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_LONG);
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
}
;
exp : 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); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
exp : variable
;
exp : DOLLAR_VARIABLE
{
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);
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
}
;
exp : SIZEOF_KEYWORD '(' type ')' %prec UNARY
{
/* TODO(dje): Go objects in structs. */
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_LONG);
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
/* TODO(dje): What's the right type here? */
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,
parse_type (pstate)->builtin_unsigned_int);
Remove CHECK_TYPEDEF, use check_typedef instead I think that the CHECK_TYPEDEF macro is not necessary, and even a bit annoying. It makes unclear the fact that the "type" variables gets overwritten. It has actually bitten me a few times. I think the following, explicit form, is better. type = check_typedef (type); This patches changes all instances of CHECK_TYPEDEF for an equivalent call to check_typedef. The bulk of the change was done with this sed: sed -i 's/CHECK_TYPEDEF (\([^)]*\));/\1 = check_typedef (\1);/' <file>.c The ChangeLog was generated using David Malcom's generate_changelog.py. I manually fixed those places where it gets the wrong function name, hopefully all of them. The patch was built-tested, and I ran a few smoke tests. gdb/ChangeLog: * gdbtypes.h (CHECK_TYPEDEF): Remove. * aarch64-tdep.c (aarch64_return_in_memory): Replace CHECK_TYPEDEF with check_typedef. * ada-lang.c (decode_constrained_packed_array_type): Likewise. (ada_array_length): Likewise. (find_parallel_type_by_descriptive_type): Likewise. (ada_check_typedef): Likewise. * arm-tdep.c (arm_return_in_memory): Likewise. * ax-gdb.c (gen_trace_static_fields): Likewise. (gen_struct_ref_recursive): Likewise. * c-exp.y (exp : SIZEOF '(' type ')' %prec UNARY): Likewise. (variable: block COLONCOLON name): Likewise. (qualified_name: TYPENAME COLONCOLON name): Likewise. * c-lang.c (classify_type): Likewise. * c-typeprint.c (c_print_type): Likewise. (c_print_typedef): Likewise. (c_type_print_base): Likewise. * c-valprint.c (c_val_print): Likewise. * compile/compile-c-types.c (convert_type): Likewise. * compile/compile-object-load.c (get_out_value_type): Likewise. * completer.c (add_struct_fields): Likewise. (expression_completer): Likewise. * cp-namespace.c (cp_find_type_baseclass_by_name): Likewise. (cp_lookup_nested_symbol_1): Likewise. (cp_lookup_nested_symbol): Likewise. * cp-valprint.c (cp_print_value_fields): Likewise. (cp_print_static_field): Likewise. * d-valprint.c (d_val_print): Likewise. * eval.c (evaluate_subexp_standard): Likewise. (evaluate_subexp_for_sizeof): Likewise. * f-exp.y (exp : SIZEOF '(' type ')' %prec UNARY): Likewise. * f-typeprint.c (f_type_print_base): Likewise. * f-valprint.c (f_val_print): Likewise. * gdbtypes.c (get_discrete_bounds): Likewise. (create_array_type_with_stride): Likewise. (type_name_no_tag_or_error): Likewise. (lookup_struct_elt_type): Likewise. (get_unsigned_type_max): Likewise. (internal_type_vptr_fieldno): Likewise. (set_type_vptr_fieldno): Likewise. (internal_type_vptr_basetype): Likewise. (set_type_vptr_basetype): Likewise. (get_vptr_fieldno): Likewise. (is_integral_type): Likewise. (is_scalar_type): Likewise. (is_scalar_type_recursive): Likewise. (distance_to_ancestor): Likewise. (is_unique_ancestor_worker): Likewise. (check_types_equal): Likewise. * gnu-v2-abi.c (gnuv2_value_rtti_type): Likewise. * gnu-v3-abi.c (gnuv3_dynamic_class): Likewise. (gnuv3_get_vtable): Likewise. (gnuv3_pass_by_reference): Likewise. * go-exp.y (exp : SIZEOF_KEYWORD '(' type ')' %prec UNARY): Likewise. * go-lang.c (gccgo_string_p): Likewise. (go_classify_struct_type): Likewise. * go-typeprint.c (go_print_type): Likewise. * go-valprint.c (go_val_print): Likewise. * guile/scm-math.c (vlscm_binop): Likewise. * guile/scm-value.c (gdbscm_value_dynamic_type): Likewise. (gdbscm_value_to_bytevector): Likewise. (gdbscm_value_to_bool): Likewise. (gdbscm_value_to_integer): Likewise. (gdbscm_value_to_real): Likewise. * infcall.c (call_function_by_hand_dummy): Likewise. * infcmd.c (get_return_value): Likewise. * jv-lang.c (is_object_type): Likewise. * jv-typeprint.c (java_type_print_base): Likewise. * jv-valprint.c (java_print_value_fields): Likewise. (java_val_print): Likewise. * linespec.c (find_methods): Likewise. (collect_one_symbol): Likewise. * m2-typeprint.c (m2_print_type): Likewise. (m2_print_typedef): Likewise. (m2_get_discrete_bounds): Likewise. * m2-valprint.c (m2_print_long_set): Likewise. (m2_print_unbounded_array): Likewise. (m2_print_array_contents): Likewise. (m2_val_print): Likewise. * opencl-lang.c (opencl_print_type): Likewise. * p-exp.y (exp : SIZEOF '(' type ')' %prec UNARY): Likewise. * p-typeprint.c (pascal_print_type): Likewise. (pascal_print_typedef): Likewise. (pascal_type_print_base): Likewise. * p-valprint.c (pascal_val_print): Likewise. (pascal_object_print_value_fields): Likewise. (pascal_object_print_static_field): Likewise. * python/py-type.c (typy_fields_items): Likewise. (typy_get_composite): Likewise. * python/py-value.c (valpy_get_dynamic_type): Likewise. (valpy_binop): Likewise. (valpy_long): Likewise. (valpy_float): Likewise. * stack.c (return_command): Likewise. * symtab.c (check_field): Likewise. (lookup_symbol_aux): Likewise. * tic6x-tdep.c (tic6x_return_value): Likewise. * typeprint.c (print_type_scalar): Likewise. * valarith.c (value_vector_widen): Likewise. * valops.c (value_cast): Likewise. (value_assign): Likewise. (do_search_struct_field): Likewise. (search_struct_method): Likewise. (find_method_list): Likewise. * valprint.c (val_print_scalar_type_p): Likewise. (valprint_check_validity): Likewise. (generic_val_print): Likewise. * value.c (unpack_double): Likewise. (value_primitive_field): Likewise. (unpack_bits_as_long): Likewise.
2015-07-06 22:05:06 +02:00
$3 = check_typedef ($3);
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_longcst (pstate,
(LONGEST) TYPE_LENGTH ($3));
write_exp_elt_opcode (pstate, OP_LONG);
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
}
;
exp : SIZEOF_KEYWORD '(' exp ')' %prec UNARY
{
/* TODO(dje): Go objects in structs. */
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_SIZEOF);
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
}
string_exp:
STRING
{
/* We copy the string here, and not in the
lexer, to guarantee that we do not leak a
string. */
/* Note that we NUL-terminate here, but just
for convenience. */
struct typed_stoken *vec = XNEW (struct typed_stoken);
$$.len = 1;
$$.tokens = vec;
vec->type = $1.type;
vec->length = $1.length;
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
vec->ptr = (char *) malloc ($1.length + 1);
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
memcpy (vec->ptr, $1.ptr, $1.length + 1);
}
| string_exp '+' STRING
{
/* Note that we NUL-terminate here, but just
for convenience. */
char *p;
++$$.len;
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
$$.tokens = XRESIZEVEC (struct typed_stoken,
$$.tokens, $$.len);
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
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
p = (char *) malloc ($3.length + 1);
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
memcpy (p, $3.ptr, $3.length + 1);
$$.tokens[$$.len - 1].type = $3.type;
$$.tokens[$$.len - 1].length = $3.length;
$$.tokens[$$.len - 1].ptr = p;
}
;
exp : string_exp %prec ABOVE_COMMA
{
int i;
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_string_vector (pstate, 0 /*always utf8*/,
&$1);
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
for (i = 0; i < $1.len; ++i)
free ($1.tokens[i].ptr);
free ($1.tokens);
}
;
exp : TRUE_KEYWORD
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_BOOL);
write_exp_elt_longcst (pstate, (LONGEST) $1);
write_exp_elt_opcode (pstate, OP_BOOL); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
exp : FALSE_KEYWORD
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_BOOL);
write_exp_elt_longcst (pstate, (LONGEST) $1);
write_exp_elt_opcode (pstate, OP_BOOL); }
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
;
variable: name_not_typename ENTRY
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 symbol *sym = $1.sym.symbol;
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
if (sym == NULL
|| !SYMBOL_IS_ARGUMENT (sym)
|| !symbol_read_needs_frame (sym))
error (_("@entry can be used only for function "
"parameters, not for \"%s\""),
copy_name ($1.stoken).c_str ());
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07: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
write_exp_elt_opcode (pstate, OP_VAR_ENTRY_VALUE);
write_exp_elt_sym (pstate, sym);
write_exp_elt_opcode (pstate, OP_VAR_ENTRY_VALUE);
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
}
;
variable: name_not_typename
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 = $1.sym;
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
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.symbol)
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
{
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 (symbol_read_needs_frame (sym.symbol))
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
pstate->block_tracker->update (sym);
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07: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
write_exp_elt_opcode (pstate, OP_VAR_VALUE);
DWARF: handle non-local references in nested functions GDB's current behavior when dealing with non-local references in the context of nested fuctions is approximative: - code using valops.c:value_of_variable read the first available stack frame that holds the corresponding variable (whereas there can be multiple candidates for this); - code directly relying on read_var_value will instead read non-local variables in frames where they are not even defined. This change adds the necessary context to symbol reads (to get the block they belong to) and to blocks (the static link property, if any) so that GDB can make the proper decisions when dealing with non-local varibale references. gdb/ChangeLog: * ada-lang.c (ada_read_var_value): Add a var_block argument and pass it to default_read_var_value. * block.c (block_static_link): New accessor. * block.h (block_static_link): Declare it. * buildsym.c (finish_block_internal): Add a static_link argument. If there is a static link, associate it to the new block. (finish_block): Add a static link argument and pass it to finish_block_internal. (end_symtab_get_static_block): Update calls to finish_block and to finish_block_internal. (end_symtab_with_blockvector): Update call to finish_block_internal. * buildsym.h: Forward-declare struct dynamic_prop. (struct context_stack): Add a static_link field. (finish_block): Add a static link argument. * c-exp.y: Remove an obsolete comment (evaluation of variables already start from the selected frame, and now they climb *up* the call stack) and propagate the block information to the produced expression. * d-exp.y: Likewise. * f-exp.y: Likewise. * go-exp.y: Likewise. * jv-exp.y: Likewise. * m2-exp.y: Likewise. * p-exp.y: Likewise. * coffread.c (coff_symtab_read): Update calls to finish_block. * dbxread.c (process_one_symbol): Likewise. * xcoffread.c (read_xcoff_symtab): Likewise. * compile/compile-c-symbols.c (convert_one_symbol): Promote the "sym" parameter to struct block_symbol, update its uses and pass its block to calls to read_var_value. (convert_symbol_sym): Update the calls to convert_one_symbol. * compile/compile-loc2c.c (do_compile_dwarf_expr_to_c): Update call to read_var_value. * dwarf2loc.c (block_op_get_frame_base): New. (dwarf2_block_frame_base_locexpr_funcs): Implement the get_frame_base method. (dwarf2_block_frame_base_loclist_funcs): Likewise. (dwarf2locexpr_baton_eval): Add a frame argument and use it instead of the selected frame in order to evaluate the expression. (dwarf2_evaluate_property): Add a frame argument. Update call to dwarf2_locexpr_baton_eval to provide a frame in available and to handle the absence of address stack. * dwarf2loc.h (dwarf2_evaluate_property): Add a frame argument. * dwarf2read.c (attr_to_dynamic_prop): Add a forward declaration. (read_func_scope): Record any available static link description. Update call to finish_block. (read_lexical_block_scope): Update call to finish_block. * findvar.c (follow_static_link): New. (get_hosting_frame): New. (default_read_var_value): Add a var_block argument. Use get_hosting_frame to handle non-local references. (read_var_value): Add a var_block argument and pass it to the LA_READ_VAR_VALUE method. * gdbtypes.c (resolve_dynamic_range): Update calls to dwarf2_evaluate_property. (resolve_dynamic_type_internal): Likewise. * guile/scm-frame.c (gdbscm_frame_read_var): Update call to read_var_value, passing it the block coming from symbol lookup. * guile/scm-symbol.c (gdbscm_symbol_value): Update call to read_var_value (TODO). * infcmd.c (finish_command_continuation): Update call to read_var_value, passing it the block coming from symbol lookup. * infrun.c (insert_exception_resume_breakpoint): Likewise. * language.h (struct language_defn): Add a var_block argument to the LA_READ_VAR_VALUE method. * objfiles.c (struct static_link_htab_entry): New. (static_link_htab_entry_hash): New. (static_link_htab_entry_eq): New. (objfile_register_static_link): New. (objfile_lookup_static_link): New. (free_objfile): Free the STATIC_LINKS hashed map if needed. * objfiles.h: Include hashtab.h. (struct objfile): Add a static_links field. (objfile_register_static_link): New. (objfile_lookup_static_link): New. * printcmd.c (print_variable_and_value): Update call to read_var_value. * python/py-finishbreakpoint.c (bpfinishpy_init): Likewise. * python/py-frame.c (frapy_read_var): Update call to read_var_value, passing it the block coming from symbol lookup. * python/py-framefilter.c (extract_sym): Add a sym_block parameter and set the pointed value to NULL (TODO). (enumerate_args): Update call to extract_sym. (enumerate_locals): Update calls to extract_sym and to read_var_value. * python/py-symbol.c (sympy_value): Update call to read_var_value (TODO). * stack.c (read_frame_local): Update call to read_var_value. (read_frame_arg): Likewise. (return_command): Likewise. * symtab.h (struct symbol_block_ops): Add a get_frame_base method. (struct symbol): Add a block field. (SYMBOL_BLOCK): New accessor. * valops.c (value_of_variable): Remove frame/block handling and pass the block argument to read_var_value, which does this job now. (value_struct_elt_for_reference): Update calls to read_var_value. (value_of_this): Pass the block found to read_var_value. * value.h (read_var_value): Add a var_block argument. (default_read_var_value): Likewise. gdb/testsuite/ChangeLog: * gdb.base/nested-subp1.exp: New file. * gdb.base/nested-subp1.c: New file. * gdb.base/nested-subp2.exp: New file. * gdb.base/nested-subp2.c: New file. * gdb.base/nested-subp3.exp: New file. * gdb.base/nested-subp3.c: New file.
2015-02-05 17:00:06 +01:00
write_exp_elt_block (pstate, sym.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
write_exp_elt_sym (pstate, sym.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_exp_elt_opcode (pstate, OP_VAR_VALUE);
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
}
else if ($1.is_a_field_of_this)
{
/* TODO(dje): Can we get here?
E.g., via a mix of c++ and go? */
gdb_assert_not_reached ("go with `this' field");
}
else
{
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 msymbol;
std::string arg = copy_name ($1.stoken);
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
msymbol =
lookup_bound_minimal_symbol (arg.c_str ());
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 (msymbol.minsym != 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_msymbol (pstate, msymbol);
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
else if (!have_full_symbols ()
&& !have_partial_symbols ())
error (_("No symbol table is loaded. "
"Use the \"file\" command."));
else
error (_("No symbol \"%s\" in current context."),
arg.c_str ());
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
}
}
;
/* TODO
method_exp: PACKAGENAME '.' name '.' name
{
}
;
*/
type /* Implements (approximately): [*] type-specifier */
: '*' type
{ $$ = lookup_pointer_type ($2); }
| TYPENAME
{ $$ = $1.type; }
/*
| STRUCT_KEYWORD name
{ $$ = lookup_struct (copy_name ($2),
expression_context_block); }
*/
| BYTE_KEYWORD
{ $$ = builtin_go_type (pstate->gdbarch ())
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
->builtin_uint8; }
;
/* TODO
name : NAME { $$ = $1.stoken; }
| TYPENAME { $$ = $1.stoken; }
| NAME_OR_INT { $$ = $1.stoken; }
;
*/
name_not_typename
: NAME
/* These would be useful if name_not_typename was useful, but it is just
a fake for "variable", so these cause reduce/reduce conflicts because
the parser can't tell whether NAME_OR_INT is a name_not_typename (=variable,
=exp) or just an exp. If name_not_typename was ever used in an lvalue
context where only a name could occur, this might be useful.
| NAME_OR_INT
*/
;
%%
/* Take care of parsing a number (anything that starts with a digit).
Set yylval and return the token type; update lexptr.
LEN is the number of characters in it. */
/* FIXME: Needs some error checking for the float case. */
/* FIXME(dje): IWBN to use c-exp.y's parse_number if we could.
That will require moving the guts into a function that we both call
as our YYSTYPE is different than c-exp.y's */
static 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
parse_number (struct parser_state *par_state,
const char *p, int len, int parsed_float, YYSTYPE *putithere)
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
{
/* FIXME: Shouldn't these be unsigned? We don't deal with negative values
here, and we do kind of silly things like cast to unsigned. */
LONGEST n = 0;
LONGEST prevn = 0;
ULONGEST un;
int i = 0;
int c;
int base = input_radix;
int unsigned_p = 0;
/* Number of "L" suffixes encountered. */
int long_p = 0;
/* We have found a "L" or "U" suffix. */
int found_suffix = 0;
ULONGEST high_bit;
struct type *signed_type;
struct type *unsigned_type;
if (parsed_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
const struct builtin_go_type *builtin_go_types
= builtin_go_type (par_state->gdbarch ());
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
/* Handle suffixes: 'f' for float32, 'l' for long double.
FIXME: This appears to be an extension -- do we want this? */
if (len >= 1 && tolower (p[len - 1]) == 'f')
{
putithere->typed_val_float.type
= builtin_go_types->builtin_float32;
len--;
}
else if (len >= 1 && tolower (p[len - 1]) == 'l')
{
putithere->typed_val_float.type
= parse_type (par_state)->builtin_long_double;
len--;
}
/* Default type for floating-point literals is float64. */
else
{
putithere->typed_val_float.type
= builtin_go_types->builtin_float64;
}
if (!parse_float (p, len,
putithere->typed_val_float.type,
putithere->typed_val_float.val))
return ERROR;
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
return FLOAT;
}
/* Handle base-switching prefixes 0x, 0t, 0d, 0. */
if (p[0] == '0')
switch (p[1])
{
case 'x':
case 'X':
if (len >= 3)
{
p += 2;
base = 16;
len -= 2;
}
break;
case 'b':
case 'B':
if (len >= 3)
{
p += 2;
base = 2;
len -= 2;
}
break;
case 't':
case 'T':
case 'd':
case 'D':
if (len >= 3)
{
p += 2;
base = 10;
len -= 2;
}
break;
default:
base = 8;
break;
}
while (len-- > 0)
{
c = *p++;
if (c >= 'A' && c <= 'Z')
c += 'a' - 'A';
if (c != 'l' && c != 'u')
n *= base;
if (c >= '0' && c <= '9')
{
if (found_suffix)
return ERROR;
n += i = c - '0';
}
else
{
if (base > 10 && c >= 'a' && c <= 'f')
{
if (found_suffix)
return ERROR;
n += i = c - 'a' + 10;
}
else if (c == 'l')
{
++long_p;
found_suffix = 1;
}
else if (c == 'u')
{
unsigned_p = 1;
found_suffix = 1;
}
else
return ERROR; /* Char not a digit */
}
if (i >= base)
return ERROR; /* Invalid digit in this base. */
/* Portably test for overflow (only works for nonzero values, so make
a second check for zero). FIXME: Can't we just make n and prevn
unsigned and avoid this? */
if (c != 'l' && c != 'u' && (prevn >= n) && n != 0)
unsigned_p = 1; /* Try something unsigned. */
/* Portably test for unsigned overflow.
FIXME: This check is wrong; for example it doesn't find overflow
on 0x123456789 when LONGEST is 32 bits. */
if (c != 'l' && c != 'u' && n != 0)
{
if ((unsigned_p && (ULONGEST) prevn >= (ULONGEST) n))
error (_("Numeric constant too large."));
}
prevn = n;
}
/* An integer constant is an int, a long, or a long long. An L
suffix forces it to be long; an LL suffix forces it to be long
long. If not forced to a larger size, it gets the first type of
the above that it fits in. To figure out whether it fits, we
shift it right and see whether anything remains. Note that we
can't shift sizeof (LONGEST) * HOST_CHAR_BIT bits or more in one
operation, because many compilers will warn about such a shift
(which always produces a zero result). Sometimes gdbarch_int_bit
or gdbarch_long_bit will be that big, sometimes not. To deal with
the case where it is we just always shift the value more than
once, with fewer bits each time. */
un = (ULONGEST)n >> 2;
if (long_p == 0
&& (un >> (gdbarch_int_bit (par_state->gdbarch ()) - 2)) == 0)
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07: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
high_bit
= ((ULONGEST)1) << (gdbarch_int_bit (par_state->gdbarch ()) - 1);
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
/* A large decimal (not hex or octal) constant (between INT_MAX
and UINT_MAX) is a long or unsigned long, according to ANSI,
never an unsigned int, but this code treats it as unsigned
int. This probably should be fixed. GCC gives a warning on
such constants. */
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
unsigned_type = parse_type (par_state)->builtin_unsigned_int;
signed_type = parse_type (par_state)->builtin_int;
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
}
else if (long_p <= 1
&& (un >> (gdbarch_long_bit (par_state->gdbarch ()) - 2)) == 0)
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07: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
high_bit
= ((ULONGEST)1) << (gdbarch_long_bit (par_state->gdbarch ()) - 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
unsigned_type = parse_type (par_state)->builtin_unsigned_long;
signed_type = parse_type (par_state)->builtin_long;
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
}
else
{
int shift;
if (sizeof (ULONGEST) * HOST_CHAR_BIT
< gdbarch_long_long_bit (par_state->gdbarch ()))
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
/* A long long does not fit in a LONGEST. */
shift = (sizeof (ULONGEST) * HOST_CHAR_BIT - 1);
else
shift = (gdbarch_long_long_bit (par_state->gdbarch ()) - 1);
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
high_bit = (ULONGEST) 1 << shift;
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
unsigned_type = parse_type (par_state)->builtin_unsigned_long_long;
signed_type = parse_type (par_state)->builtin_long_long;
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
}
putithere->typed_val_int.val = n;
/* If the high bit of the worked out type is set then this number
has to be unsigned. */
if (unsigned_p || (n & high_bit))
{
putithere->typed_val_int.type = unsigned_type;
}
else
{
putithere->typed_val_int.type = signed_type;
}
return INT;
}
/* Temporary obstack used for holding strings. */
static struct obstack tempbuf;
static int tempbuf_init;
/* Parse a string or character literal from TOKPTR. The string or
character may be wide or unicode. *OUTPTR is set to just after the
end of the literal in the input string. The resulting token is
stored in VALUE. This returns a token value, either STRING or
CHAR, depending on what was parsed. *HOST_CHARS is set to the
number of host characters in the literal. */
static int
parse_string_or_char (const char *tokptr, const char **outptr,
struct typed_stoken *value, int *host_chars)
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
{
int quote;
/* Build the gdb internal form of the input string in tempbuf. Note
that the buffer is null byte terminated *only* for the
convenience of debugging gdb itself and printing the buffer
contents when the buffer contains no embedded nulls. Gdb does
not depend upon the buffer being null byte terminated, it uses
the length string instead. This allows gdb to handle C strings
(as well as strings in other languages) with embedded null
bytes */
if (!tempbuf_init)
tempbuf_init = 1;
else
obstack_free (&tempbuf, NULL);
obstack_init (&tempbuf);
/* Skip the quote. */
quote = *tokptr;
++tokptr;
*host_chars = 0;
while (*tokptr)
{
char c = *tokptr;
if (c == '\\')
{
++tokptr;
*host_chars += c_parse_escape (&tokptr, &tempbuf);
}
else if (c == quote)
break;
else
{
obstack_1grow (&tempbuf, c);
++tokptr;
/* FIXME: this does the wrong thing with multi-byte host
characters. We could use mbrlen here, but that would
make "set host-charset" a bit less useful. */
++*host_chars;
}
}
if (*tokptr != quote)
{
if (quote == '"')
error (_("Unterminated string in expression."));
else
error (_("Unmatched single quote."));
}
++tokptr;
value->type = C_STRING | (quote == '\'' ? C_CHAR : 0); /*FIXME*/
value->ptr = (char *) obstack_base (&tempbuf);
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
value->length = obstack_object_size (&tempbuf);
*outptr = tokptr;
return quote == '\'' ? CHAR : STRING;
}
struct token
{
-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
const char *oper;
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
int token;
enum exp_opcode opcode;
};
static const struct token tokentab3[] =
{
{">>=", ASSIGN_MODIFY, BINOP_RSH},
{"<<=", ASSIGN_MODIFY, BINOP_LSH},
/*{"&^=", ASSIGN_MODIFY, BINOP_BITWISE_ANDNOT}, TODO */
{"...", DOTDOTDOT, OP_NULL},
};
static const struct token tokentab2[] =
{
{"+=", ASSIGN_MODIFY, BINOP_ADD},
{"-=", ASSIGN_MODIFY, BINOP_SUB},
{"*=", ASSIGN_MODIFY, BINOP_MUL},
{"/=", ASSIGN_MODIFY, BINOP_DIV},
{"%=", ASSIGN_MODIFY, BINOP_REM},
{"|=", ASSIGN_MODIFY, BINOP_BITWISE_IOR},
{"&=", ASSIGN_MODIFY, BINOP_BITWISE_AND},
{"^=", ASSIGN_MODIFY, BINOP_BITWISE_XOR},
{"++", INCREMENT, BINOP_END},
{"--", DECREMENT, BINOP_END},
/*{"->", RIGHT_ARROW, BINOP_END}, Doesn't exist in Go. */
{"<-", LEFT_ARROW, BINOP_END},
{"&&", ANDAND, BINOP_END},
{"||", OROR, BINOP_END},
{"<<", LSH, BINOP_END},
{">>", RSH, BINOP_END},
{"==", EQUAL, BINOP_END},
{"!=", NOTEQUAL, BINOP_END},
{"<=", LEQ, BINOP_END},
{">=", GEQ, BINOP_END},
/*{"&^", ANDNOT, BINOP_END}, TODO */
};
/* Identifier-like tokens. */
static const struct token ident_tokens[] =
{
{"true", TRUE_KEYWORD, OP_NULL},
{"false", FALSE_KEYWORD, OP_NULL},
{"nil", NIL_KEYWORD, OP_NULL},
{"const", CONST_KEYWORD, OP_NULL},
{"struct", STRUCT_KEYWORD, OP_NULL},
{"type", TYPE_KEYWORD, OP_NULL},
{"interface", INTERFACE_KEYWORD, OP_NULL},
{"chan", CHAN_KEYWORD, OP_NULL},
{"byte", BYTE_KEYWORD, OP_NULL}, /* An alias of uint8. */
{"len", LEN_KEYWORD, OP_NULL},
{"cap", CAP_KEYWORD, OP_NULL},
{"new", NEW_KEYWORD, OP_NULL},
{"iota", IOTA_KEYWORD, OP_NULL},
};
/* This is set if a NAME token appeared at the very end of the input
string, with no whitespace separating the name from the EOF. This
is used only when parsing to do field name completion. */
static int saw_name_at_eof;
/* This is set if the previously-returned token was a structure
operator -- either '.' or ARROW. This is used only when parsing to
do field name completion. */
static int last_was_structop;
/* Depth of parentheses. */
static int paren_depth;
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
/* Read one token, getting characters through lexptr. */
static 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
lex_one_token (struct parser_state *par_state)
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
{
int c;
int namelen;
unsigned int i;
const char *tokstart;
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
int saw_structop = last_was_structop;
last_was_structop = 0;
retry:
par_state->prev_lexptr = par_state->lexptr;
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
tokstart = par_state->lexptr;
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
/* See if it is a special token of length 3. */
for (i = 0; i < sizeof (tokentab3) / sizeof (tokentab3[0]); i++)
if (strncmp (tokstart, tokentab3[i].oper, 3) == 0)
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
{
par_state->lexptr += 3;
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
yylval.opcode = tokentab3[i].opcode;
return tokentab3[i].token;
}
/* See if it is a special token of length 2. */
for (i = 0; i < sizeof (tokentab2) / sizeof (tokentab2[0]); i++)
if (strncmp (tokstart, tokentab2[i].oper, 2) == 0)
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
{
par_state->lexptr += 2;
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
yylval.opcode = tokentab2[i].opcode;
/* NOTE: -> doesn't exist in Go, so we don't need to watch for
setting last_was_structop here. */
return tokentab2[i].token;
}
switch (c = *tokstart)
{
case 0:
if (saw_name_at_eof)
{
saw_name_at_eof = 0;
return COMPLETE;
}
else if (saw_structop)
return COMPLETE;
else
return 0;
case ' ':
case '\t':
case '\n':
par_state->lexptr++;
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
goto retry;
case '[':
case '(':
paren_depth++;
par_state->lexptr++;
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
return c;
case ']':
case ')':
if (paren_depth == 0)
return 0;
paren_depth--;
par_state->lexptr++;
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
return c;
case ',':
if (pstate->comma_terminates
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
&& paren_depth == 0)
return 0;
par_state->lexptr++;
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
return c;
case '.':
/* Might be a floating point number. */
if (par_state->lexptr[1] < '0' || par_state->lexptr[1] > '9')
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
{
Move completion parsing to parser_state This moves the globals and functions related to parsing for completion to parser_state. A new structure is introduced in order to return completion results from the parse back to parse_expression_for_completion. gdb/ChangeLog 2019-04-04 Tom Tromey <tom@tromey.com> * rust-exp.y (rust_parser::lex_identifier, rustyylex) (rust_parser::convert_ast_to_expression, rust_parse) (rust_lex_test_completion, rust_lex_tests): Update. * parser-defs.h (struct expr_completion_state): New. (struct parser_state) <parser_state>: Add completion parameter. <mark_struct_expression, mark_completion_tag>: New methods. <parse_completion, m_completion_state>: New members. (prefixify_expression, null_post_parser): Update. (mark_struct_expression, mark_completion_tag): Don't declare. * parse.c (parse_completion, expout_last_struct) (expout_tag_completion_type, expout_completion_name): Remove globals. (parser_state::mark_struct_expression) (parser_state::mark_completion_tag): Now methods. (prefixify_expression): Add last_struct parameter. (prefixify_subexp): Likewise. (parse_exp_1): Update. (parse_exp_in_context): Add cstate parameter. Update. (parse_expression_for_completion): Create an expr_completion_state. (null_post_parser): Add "completion" parameter. * p-exp.y: Update rules. (yylex): Update. * language.h (struct language_defn) <la_post_parser>: Add "completing" parameter. * go-exp.y: Update rules. (lex_one_token): Update. * expression.h (parse_completion): Don't declare. * d-exp.y: Update rules. (lex_one_token): Update rules. * c-exp.y: Update rules. (lex_one_token): Update. * ada-lang.c (resolve): Add "parse_completion" parameter. (resolve_subexp): Likewise. (ada_resolve_function): Likewise.
2019-03-25 05:50:14 +01:00
if (pstate->parse_completion)
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
last_was_structop = 1;
goto symbol; /* Nope, must be a symbol. */
}
Fix "fall through" comments This patch updates existing "fall through" comments so that they can be recognized by gcc's -Wimplicit-fallthrough comment-parsing heuristic. ChangeLog 2018-05-04 Tom Tromey <tom@tromey.com> * s390-tdep.c (s390_process_record): Fix fall-through comments. * xcoffread.c (scan_xcoff_symtab): Move comment later. * symfile.c (section_is_mapped): Fix fall-through comment. * stabsread.c (define_symbol, read_member_functions): Fix fall-through comment. * s390-linux-tdep.c (s390_process_record): Fix fall-through comment. * remote.c (remote_wait_as): Fix fall-through comment. * p-exp.y (yylex): Fix fall-through comment. * nat/x86-dregs.c (x86_length_and_rw_bits): Fix fall-through comment. * msp430-tdep.c (msp430_gdbarch_init): Fix fall-through comment. * mdebugread.c (parse_partial_symbols): Fix fall-through comment. * jv-exp.y (yylex): Fix fall-through comment. * go-exp.y (lex_one_token): Fix fall-through comment. * gdbtypes.c (get_discrete_bounds, rank_one_type): Fix fall-through comment. * f-exp.y (yylex): Fix fall-through comment. * dwarf2read.c (process_die): Fix fall-through comments. * dbxread.c (process_one_symbol): Fix fall-through comment. * d-exp.y (lex_one_token): Fix fall-through comment. * cp-name-parser.y (yylex): Fix fall-through comment. * coffread.c (coff_symtab_read): Fix fall-through comment. * c-exp.y (lex_one_token): Fix fall-through comment. * arm-tdep.c (arm_decode_miscellaneous): Fix fall-through comment. * arch/arm.c (arm_instruction_changes_pc): Fix fall-through comment.
2016-09-27 19:18:04 +02:00
/* FALL THRU. */
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
{
/* It's a number. */
int got_dot = 0, got_e = 0, toktype;
const char *p = tokstart;
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
int hex = input_radix > 10;
if (c == '0' && (p[1] == 'x' || p[1] == 'X'))
{
p += 2;
hex = 1;
}
for (;; ++p)
{
/* This test includes !hex because 'e' is a valid hex digit
and thus does not indicate a floating point number when
the radix is hex. */
if (!hex && !got_e && (*p == 'e' || *p == 'E'))
got_dot = got_e = 1;
/* This test does not include !hex, because a '.' always indicates
a decimal floating point number regardless of the radix. */
else if (!got_dot && *p == '.')
got_dot = 1;
else if (got_e && (p[-1] == 'e' || p[-1] == 'E')
&& (*p == '-' || *p == '+'))
/* This is the sign of the exponent, not the end of the
number. */
continue;
/* We will take any letters or digits. parse_number will
complain if past the radix, or if L or U are not final. */
else if ((*p < '0' || *p > '9')
&& ((*p < 'a' || *p > 'z')
&& (*p < 'A' || *p > 'Z')))
break;
}
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
toktype = parse_number (par_state, tokstart, p - tokstart,
got_dot|got_e, &yylval);
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
if (toktype == ERROR)
{
char *err_copy = (char *) alloca (p - tokstart + 1);
memcpy (err_copy, tokstart, p - tokstart);
err_copy[p - tokstart] = 0;
error (_("Invalid number \"%s\"."), err_copy);
}
par_state->lexptr = p;
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
return toktype;
}
case '@':
{
const char *p = &tokstart[1];
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
size_t len = strlen ("entry");
while (isspace (*p))
p++;
if (strncmp (p, "entry", len) == 0 && !isalnum (p[len])
&& p[len] != '_')
{
par_state->lexptr = &p[len];
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
return ENTRY;
}
}
/* FALLTHRU */
case '+':
case '-':
case '*':
case '/':
case '%':
case '|':
case '&':
case '^':
case '~':
case '!':
case '<':
case '>':
case '?':
case ':':
case '=':
case '{':
case '}':
symbol:
par_state->lexptr++;
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
return c;
case '\'':
case '"':
case '`':
{
int host_len;
int result = parse_string_or_char (tokstart, &par_state->lexptr,
&yylval.tsval, &host_len);
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
if (result == CHAR)
{
if (host_len == 0)
error (_("Empty character constant."));
else if (host_len > 2 && c == '\'')
{
++tokstart;
namelen = par_state->lexptr - tokstart - 1;
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
goto tryname;
}
else if (host_len > 1)
error (_("Invalid character constant."));
}
return result;
}
}
if (!(c == '_' || c == '$'
|| (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')))
/* We must have come across a bad character (e.g. ';'). */
error (_("Invalid character '%c' in expression."), c);
/* It's a name. See how long it is. */
namelen = 0;
for (c = tokstart[namelen];
(c == '_' || c == '$' || (c >= '0' && c <= '9')
|| (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'));)
{
c = tokstart[++namelen];
}
/* The token "if" terminates the expression and is NOT removed from
the input stream. It doesn't count if it appears in the
expansion of a macro. */
if (namelen == 2
&& tokstart[0] == 'i'
&& tokstart[1] == 'f')
{
return 0;
}
/* For the same reason (breakpoint conditions), "thread N"
terminates the expression. "thread" could be an identifier, but
an identifier is never followed by a number without intervening
punctuation.
Handle abbreviations of these, similarly to
breakpoint.c:find_condition_and_thread.
TODO: Watch for "goroutine" here? */
if (namelen >= 1
&& strncmp (tokstart, "thread", namelen) == 0
&& (tokstart[namelen] == ' ' || tokstart[namelen] == '\t'))
{
const char *p = tokstart + namelen + 1;
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
while (*p == ' ' || *p == '\t')
p++;
if (*p >= '0' && *p <= '9')
return 0;
}
par_state->lexptr += namelen;
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
tryname:
yylval.sval.ptr = tokstart;
yylval.sval.length = namelen;
/* Catch specific keywords. */
std::string copy = copy_name (yylval.sval);
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
for (i = 0; i < sizeof (ident_tokens) / sizeof (ident_tokens[0]); i++)
if (copy == ident_tokens[i].oper)
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
{
/* It is ok to always set this, even though we don't always
strictly need to. */
yylval.opcode = ident_tokens[i].opcode;
return ident_tokens[i].token;
}
if (*tokstart == '$')
return DOLLAR_VARIABLE;
Move completion parsing to parser_state This moves the globals and functions related to parsing for completion to parser_state. A new structure is introduced in order to return completion results from the parse back to parse_expression_for_completion. gdb/ChangeLog 2019-04-04 Tom Tromey <tom@tromey.com> * rust-exp.y (rust_parser::lex_identifier, rustyylex) (rust_parser::convert_ast_to_expression, rust_parse) (rust_lex_test_completion, rust_lex_tests): Update. * parser-defs.h (struct expr_completion_state): New. (struct parser_state) <parser_state>: Add completion parameter. <mark_struct_expression, mark_completion_tag>: New methods. <parse_completion, m_completion_state>: New members. (prefixify_expression, null_post_parser): Update. (mark_struct_expression, mark_completion_tag): Don't declare. * parse.c (parse_completion, expout_last_struct) (expout_tag_completion_type, expout_completion_name): Remove globals. (parser_state::mark_struct_expression) (parser_state::mark_completion_tag): Now methods. (prefixify_expression): Add last_struct parameter. (prefixify_subexp): Likewise. (parse_exp_1): Update. (parse_exp_in_context): Add cstate parameter. Update. (parse_expression_for_completion): Create an expr_completion_state. (null_post_parser): Add "completion" parameter. * p-exp.y: Update rules. (yylex): Update. * language.h (struct language_defn) <la_post_parser>: Add "completing" parameter. * go-exp.y: Update rules. (lex_one_token): Update. * expression.h (parse_completion): Don't declare. * d-exp.y: Update rules. (lex_one_token): Update rules. * c-exp.y: Update rules. (lex_one_token): Update. * ada-lang.c (resolve): Add "parse_completion" parameter. (resolve_subexp): Likewise. (ada_resolve_function): Likewise.
2019-03-25 05:50:14 +01:00
if (pstate->parse_completion && *par_state->lexptr == '\0')
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
saw_name_at_eof = 1;
return NAME;
}
/* An object of this type is pushed on a FIFO by the "outer" lexer. */
struct token_and_value
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
{
int token;
YYSTYPE value;
};
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
/* A FIFO of tokens that have been read but not yet returned to the
parser. */
static std::vector<token_and_value> token_fifo;
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
/* Non-zero if the lexer should return tokens from the FIFO. */
static int popping;
/* Temporary storage for yylex; this holds symbol names as they are
built up. */
Eliminate make_cleanup_obstack_free, introduce auto_obstack This commit eliminates make_cleanup_obstack_free, replacing it with a new auto_obstack type that inherits obstack to add cdtors. These changes in the parsers may not be obvious: - obstack_init (&name_obstack); - make_cleanup_obstack_free (&name_obstack); + name_obstack.clear (); Here, the 'name_obstack' variable is a global. The change means that the obstack's contents from a previous parse will stay around until the next parsing starts. I.e., memory won't be reclaimed until then. I don't think that's a problem, these objects don't really grow much at all. The other option I tried was to add a separate type that is like auto_obstack but manages an external obstack, just for those cases. I like the current approach better as that other approach adds more boilerplate and yet another type to learn. gdb/ChangeLog: 2017-06-27 Pedro Alves <palves@redhat.com> * c-exp.y (name_obstack): Now an auto_obstack. (yylex): Use auto_obstack::clear. (c_parse): Use auto_obstack::clear instead of reinitializing and freeing the obstack. * c-lang.c (evaluate_subexp_c): Use auto_obstack. * d-exp.y (name_obstack): Now an auto_obstack. (yylex): Use auto_obstack::clear. (d_parse): Use auto_obstack::clear instead of reinitializing and freeing the obstack. * dwarf2loc.c (fetch_const_value_from_synthetic_pointer): Use auto_obstack. * dwarf2read.c (create_addrmap_from_index) (dwarf2_build_psymtabs_hard) (update_enumeration_type_from_children): Likewise. * gdb_obstack.h (auto_obstack): New type. * go-exp.y (name_obstack): Now an auto_obstack. (build_packaged_name): Use auto_obstack::clear. (go_parse): Use auto_obstack::clear instead of reinitializing and freeing the obstack. * linux-tdep.c (linux_make_mappings_corefile_notes): Use auto_obstack. * printcmd.c (printf_wide_c_string, ui_printf): Use auto_obstack. * rust-exp.y (work_obstack): Now an auto_obstack. (rust_parse, rust_lex_tests): Use auto_obstack::clear instead of reinitializing and freeing the obstack. * utils.c (do_obstack_free, make_cleanup_obstack_free): Delete. (host_char_to_target): Use auto_obstack. * utils.h (make_cleanup_obstack_free): Delete declaration. * valprint.c (generic_emit_char, generic_printstr): Use auto_obstack.
2017-06-27 12:07:14 +02:00
static auto_obstack name_obstack;
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
/* Build "package.name" in name_obstack.
For convenience of the caller, the name is NUL-terminated,
but the NUL is not included in the recorded length. */
static struct stoken
build_packaged_name (const char *package, int package_len,
const char *name, int name_len)
{
struct stoken result;
Eliminate make_cleanup_obstack_free, introduce auto_obstack This commit eliminates make_cleanup_obstack_free, replacing it with a new auto_obstack type that inherits obstack to add cdtors. These changes in the parsers may not be obvious: - obstack_init (&name_obstack); - make_cleanup_obstack_free (&name_obstack); + name_obstack.clear (); Here, the 'name_obstack' variable is a global. The change means that the obstack's contents from a previous parse will stay around until the next parsing starts. I.e., memory won't be reclaimed until then. I don't think that's a problem, these objects don't really grow much at all. The other option I tried was to add a separate type that is like auto_obstack but manages an external obstack, just for those cases. I like the current approach better as that other approach adds more boilerplate and yet another type to learn. gdb/ChangeLog: 2017-06-27 Pedro Alves <palves@redhat.com> * c-exp.y (name_obstack): Now an auto_obstack. (yylex): Use auto_obstack::clear. (c_parse): Use auto_obstack::clear instead of reinitializing and freeing the obstack. * c-lang.c (evaluate_subexp_c): Use auto_obstack. * d-exp.y (name_obstack): Now an auto_obstack. (yylex): Use auto_obstack::clear. (d_parse): Use auto_obstack::clear instead of reinitializing and freeing the obstack. * dwarf2loc.c (fetch_const_value_from_synthetic_pointer): Use auto_obstack. * dwarf2read.c (create_addrmap_from_index) (dwarf2_build_psymtabs_hard) (update_enumeration_type_from_children): Likewise. * gdb_obstack.h (auto_obstack): New type. * go-exp.y (name_obstack): Now an auto_obstack. (build_packaged_name): Use auto_obstack::clear. (go_parse): Use auto_obstack::clear instead of reinitializing and freeing the obstack. * linux-tdep.c (linux_make_mappings_corefile_notes): Use auto_obstack. * printcmd.c (printf_wide_c_string, ui_printf): Use auto_obstack. * rust-exp.y (work_obstack): Now an auto_obstack. (rust_parse, rust_lex_tests): Use auto_obstack::clear instead of reinitializing and freeing the obstack. * utils.c (do_obstack_free, make_cleanup_obstack_free): Delete. (host_char_to_target): Use auto_obstack. * utils.h (make_cleanup_obstack_free): Delete declaration. * valprint.c (generic_emit_char, generic_printstr): Use auto_obstack.
2017-06-27 12:07:14 +02:00
name_obstack.clear ();
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
obstack_grow (&name_obstack, package, package_len);
obstack_grow_str (&name_obstack, ".");
obstack_grow (&name_obstack, name, name_len);
obstack_grow (&name_obstack, "", 1);
result.ptr = (char *) obstack_base (&name_obstack);
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
result.length = obstack_object_size (&name_obstack) - 1;
return result;
}
/* Return non-zero if NAME is a package name.
BLOCK is the scope in which to interpret NAME; this can be NULL
to mean the global scope. */
static int
* 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
package_name_p (const char *name, const struct block *block)
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
{
struct symbol *sym;
struct field_of_this_result is_a_field_of_this;
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
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
sym = lookup_symbol (name, block, STRUCT_DOMAIN, &is_a_field_of_this).symbol;
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
if (sym
&& SYMBOL_CLASS (sym) == LOC_TYPEDEF
&& SYMBOL_TYPE (sym)->code () == TYPE_CODE_MODULE)
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
return 1;
return 0;
}
/* Classify a (potential) function in the "unsafe" package.
We fold these into "keywords" to keep things simple, at least until
something more complex is warranted. */
static int
classify_unsafe_function (struct stoken function_name)
{
std::string copy = copy_name (function_name);
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
if (copy == "Sizeof")
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
{
yylval.sval = function_name;
return SIZEOF_KEYWORD;
}
error (_("Unknown function in `unsafe' package: %s"), copy.c_str ());
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
}
/* Classify token(s) "name1.name2" where name1 is known to be a package.
The contents of the token are in `yylval'.
Updates yylval and returns the new token type.
The result is one of NAME, NAME_OR_INT, or TYPENAME. */
static int
* 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
classify_packaged_name (const struct block *block)
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
{
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;
struct field_of_this_result is_a_field_of_this;
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
std::string copy = copy_name (yylval.sval);
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
sym = lookup_symbol (copy.c_str (), block, VAR_DOMAIN, &is_a_field_of_this);
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
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.symbol)
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
{
yylval.ssym.sym = sym;
yylval.ssym.is_a_field_of_this = is_a_field_of_this.type != NULL;
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
}
return NAME;
}
/* Classify a NAME token.
The contents of the token are in `yylval'.
Updates yylval and returns the new token type.
BLOCK is the block in which lookups start; this can be NULL
to mean the global scope.
The result is one of NAME, NAME_OR_INT, or TYPENAME. */
static 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
classify_name (struct parser_state *par_state, const struct block *block)
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
{
struct type *type;
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;
struct field_of_this_result is_a_field_of_this;
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
std::string copy = copy_name (yylval.sval);
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
/* Try primitive types first so they win over bad/weird debug info. */
type = language_lookup_primitive_type (par_state->language (),
par_state->gdbarch (),
copy.c_str ());
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
if (type != NULL)
{
/* NOTE: We take advantage of the fact that yylval coming in was a
NAME, and that struct ttype is a compatible extension of struct
stoken, so yylval.tsym.stoken is already filled in. */
yylval.tsym.type = type;
return TYPENAME;
}
/* TODO: What about other types? */
sym = lookup_symbol (copy.c_str (), block, VAR_DOMAIN, &is_a_field_of_this);
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
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.symbol)
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
{
yylval.ssym.sym = sym;
yylval.ssym.is_a_field_of_this = is_a_field_of_this.type != NULL;
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
return NAME;
}
/* If we didn't find a symbol, look again in the current package.
This is to, e.g., make "p global_var" work without having to specify
the package name. We intentionally only looks for objects in the
current package. */
{
char *current_package_name = go_block_package_name (block);
if (current_package_name != NULL)
{
struct stoken sval =
build_packaged_name (current_package_name,
strlen (current_package_name),
copy.c_str (), copy.size ());
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
xfree (current_package_name);
sym = lookup_symbol (sval.ptr, block, VAR_DOMAIN,
&is_a_field_of_this);
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.symbol)
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
{
yylval.ssym.stoken = sval;
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
yylval.ssym.sym = sym;
yylval.ssym.is_a_field_of_this = is_a_field_of_this.type != NULL;
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
return NAME;
}
}
}
/* Input names that aren't symbols but ARE valid hex numbers, when
the input radix permits them, can be names or numbers depending
on the parse. Note we support radixes > 16 here. */
if ((copy[0] >= 'a' && copy[0] < 'a' + input_radix - 10)
|| (copy[0] >= 'A' && copy[0] < 'A' + input_radix - 10))
{
YYSTYPE newlval; /* Its value is ignored. */
int hextype = parse_number (par_state, copy.c_str (),
yylval.sval.length, 0, &newlval);
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
if (hextype == INT)
{
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
yylval.ssym.sym.symbol = NULL;
yylval.ssym.sym.block = NULL;
yylval.ssym.is_a_field_of_this = 0;
return NAME_OR_INT;
}
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
}
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
yylval.ssym.sym.symbol = NULL;
yylval.ssym.sym.block = NULL;
yylval.ssym.is_a_field_of_this = 0;
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
return NAME;
}
/* This is taken from c-exp.y mostly to get something working.
The basic structure has been kept because we may yet need some of it. */
static int
yylex (void)
{
token_and_value current, next;
if (popping && !token_fifo.empty ())
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
{
token_and_value tv = token_fifo[0];
token_fifo.erase (token_fifo.begin ());
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
yylval = tv.value;
/* There's no need to fall through to handle package.name
as that can never happen here. In theory. */
return tv.token;
}
popping = 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
current.token = lex_one_token (pstate);
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
/* TODO: Need a way to force specifying name1 as a package.
.name1.name2 ? */
if (current.token != NAME)
return current.token;
/* See if we have "name1 . name2". */
current.value = yylval;
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
next.token = lex_one_token (pstate);
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
next.value = yylval;
if (next.token == '.')
{
token_and_value name2;
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
name2.token = lex_one_token (pstate);
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
name2.value = yylval;
if (name2.token == NAME)
{
/* Ok, we have "name1 . name2". */
std::string copy = copy_name (current.value.sval);
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
if (copy == "unsafe")
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
{
popping = 1;
return classify_unsafe_function (name2.value.sval);
}
if (package_name_p (copy.c_str (), pstate->expression_context_block))
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
{
popping = 1;
yylval.sval = build_packaged_name (current.value.sval.ptr,
current.value.sval.length,
name2.value.sval.ptr,
name2.value.sval.length);
return classify_packaged_name (pstate->expression_context_block);
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
}
}
token_fifo.push_back (next);
token_fifo.push_back (name2);
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
}
else
token_fifo.push_back (next);
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
/* If we arrive here we don't have a package-qualified name. */
popping = 1;
yylval = current.value;
return classify_name (pstate, pstate->expression_context_block);
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
}
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
go_parse (struct parser_state *par_state)
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07: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
/* 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;
scoped_restore restore_yydebug = make_scoped_restore (&yydebug,
parser_debug);
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
/* Initialize some state used by the lexer. */
last_was_structop = 0;
saw_name_at_eof = 0;
paren_depth = 0;
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
token_fifo.clear ();
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
popping = 0;
Eliminate make_cleanup_obstack_free, introduce auto_obstack This commit eliminates make_cleanup_obstack_free, replacing it with a new auto_obstack type that inherits obstack to add cdtors. These changes in the parsers may not be obvious: - obstack_init (&name_obstack); - make_cleanup_obstack_free (&name_obstack); + name_obstack.clear (); Here, the 'name_obstack' variable is a global. The change means that the obstack's contents from a previous parse will stay around until the next parsing starts. I.e., memory won't be reclaimed until then. I don't think that's a problem, these objects don't really grow much at all. The other option I tried was to add a separate type that is like auto_obstack but manages an external obstack, just for those cases. I like the current approach better as that other approach adds more boilerplate and yet another type to learn. gdb/ChangeLog: 2017-06-27 Pedro Alves <palves@redhat.com> * c-exp.y (name_obstack): Now an auto_obstack. (yylex): Use auto_obstack::clear. (c_parse): Use auto_obstack::clear instead of reinitializing and freeing the obstack. * c-lang.c (evaluate_subexp_c): Use auto_obstack. * d-exp.y (name_obstack): Now an auto_obstack. (yylex): Use auto_obstack::clear. (d_parse): Use auto_obstack::clear instead of reinitializing and freeing the obstack. * dwarf2loc.c (fetch_const_value_from_synthetic_pointer): Use auto_obstack. * dwarf2read.c (create_addrmap_from_index) (dwarf2_build_psymtabs_hard) (update_enumeration_type_from_children): Likewise. * gdb_obstack.h (auto_obstack): New type. * go-exp.y (name_obstack): Now an auto_obstack. (build_packaged_name): Use auto_obstack::clear. (go_parse): Use auto_obstack::clear instead of reinitializing and freeing the obstack. * linux-tdep.c (linux_make_mappings_corefile_notes): Use auto_obstack. * printcmd.c (printf_wide_c_string, ui_printf): Use auto_obstack. * rust-exp.y (work_obstack): Now an auto_obstack. (rust_parse, rust_lex_tests): Use auto_obstack::clear instead of reinitializing and freeing the obstack. * utils.c (do_obstack_free, make_cleanup_obstack_free): Delete. (host_char_to_target): Use auto_obstack. * utils.h (make_cleanup_obstack_free): Delete declaration. * valprint.c (generic_emit_char, generic_printstr): Use auto_obstack.
2017-06-27 12:07:14 +02:00
name_obstack.clear ();
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
return yyparse ();
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +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)
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
{
if (pstate->prev_lexptr)
pstate->lexptr = pstate->prev_lexptr;
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
error (_("A %s in expression, near `%s'."), msg, pstate->lexptr);
Initial pass at Go language support. * NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
2012-04-25 16:07:23 +02:00
}