From e58de8a23021ce9bbdee715ac79745ebb93437a8 Mon Sep 17 00:00:00 2001 From: Fred Fish Date: Sun, 15 Nov 1992 17:28:02 +0000 Subject: * Makefile.in (SFILES_MAINDIR): Add ch-exp.y. * Makefile.in (YYFILES): Add ch-exp.tab.c. * Makefile.in (YYOBJ): Add ch-exp.tab.o. * Makefile.in (saber_gdb): Add unload of ch-exp.y and load of ch-exp.tab.c. * Makefile.in (distclean): Add target ch-exp.tab.c. * Makefile.in (realclean): Add rm of ch-exp.tab.c. * Makefile.in (c-exp.tab.c, m2-exp.tab.c): Add dependency on Makefile since it contains sed patterns used in generation. Add sed pattern to also delete #include of any malloc.h. * Makefile.in (ch-exp.tab.o, ch-exp.tab.c): New targets. * ch-exp.y: New expression parser, for GNU-Chill. * c-exp.y, expr.c, expression.h, language.c, m2-exp.y, parser-defs.h, valarith.c, valops.c, value.h: Remap macros and function names to conform to K&R terminology with respect to logical and bitwise operators: UNOP_ZEROP => UNOP_LOGICAL_NOT UNOP_LOGNOT => UNOP_COMPLEMENT BINOP_LOGAND => BINOP_BITWISE_AND BINOP_LOGXOR => BINOP_BITWISE_XOR BINOP_LOGIOR => BINOP_BITWISE_IOR BINOP_AND => BINOP_LOGICAL_AND BINOP_OR => BINOP_LOGICAL_OR PREC_OR => PREC_LOGICAL_OR PREC_AND => PREC_LOGICAL_AND PREC_LOGIOR => PREC_BITWISE_IOR PREC_LOGXOR => PREC_BITWISE_XOR PREC_LOGAND => PREC_BITWISE_AND value_zerop() => value_logical_not() value_lognot() => value_complement() * c-exp.y (c_op_print_tab): Add explicit empty terminator. * m2-exp.y (m2_op_print_tab): Add explicit empty terminator. * defs.h (enum language): Add language_chill. * dwarfread.c (set_cu_language): Add LANG_CHILL case and make LANG_MODULA2 a recognized language. * eval.c (evaluate_subexp): Add OP_BOOL case. * expprint.c (print_subexp): Add OP_BOOL case. * gdbtypes.h (enum_typecode): Note TYPE_CODE_BOOL used for Chill as well as Modula-2. * gdbtypes.y (builtin_type_chill_bool, builtin_type_chill_long, builtin_type_chill_ulong, builtin_type_chill_real): Add. * i387-tdep.c (sys/dir.h): Remove, appears to be unnecessary and is nonexistant in some SVR4 based systems. * language.c (DEFAULT_ALLOCSIZE): Change from 3 => 4. * language.c (set_language_command): Add chill. * language.c (binop_result_type, integral_type, character_type, boolean_type, structured_type, value_true, binop_type_check): Add language_chill cases. * language.h (_LANG_chill): Define. * m2-exp.y (number_sign, modblock): Make static, #ifdef out unused modblock. * m2-exp.y (ANDAND): Rename to LOGICAL_AND. * source.c (source_info): Fix minor nits, print "1 line" rather than "1 lines", and "language is ". * symfile.c (deduce_language_from_filename): Recognize the filename extensions ".chill", ".c186", and ".c286" for Chill. * valarith.c (value_binop): Handle TYPE_CODE_BOOL as well as TYPE_CODE_INT and TYPE_CODE_FLOAT. * valprint.c (val_print): Print TYPE_CODE_BOOL type values as "TRUE" or "FALSE". * valprint.c (typedef_print): Add case for language_chill. * values.c (value_from_longest): Handle TYPE_CODE_BOOL. --- gdb/.Sanitize | 1 + gdb/ChangeLog | 65 +++ gdb/Makefile.in | 38 +- gdb/c-exp.y | 35 +- gdb/ch-exp.y | 1199 +++++++++++++++++++++++++++++++++++++++++++++++++++++ gdb/defs.h | 18 +- gdb/dwarfread.c | 7 +- gdb/eval.c | 74 ++-- gdb/gdbtypes.h | 9 +- gdb/i387-tdep.c | 1 - gdb/language.c | 29 +- gdb/language.h | 1 + gdb/m2-exp.y | 29 +- gdb/parser-defs.h | 6 +- gdb/symfile.c | 45 +- gdb/valarith.c | 120 ++++-- gdb/valprint.c | 24 +- gdb/values.c | 2 +- 18 files changed, 1555 insertions(+), 148 deletions(-) create mode 100644 gdb/ch-exp.y diff --git a/gdb/.Sanitize b/gdb/.Sanitize index 8194131..b4f07e2 100644 --- a/gdb/.Sanitize +++ b/gdb/.Sanitize @@ -52,6 +52,7 @@ buildsym.c buildsym.h c-exp.y call-cmds.h +ch-exp.y coffread.c command.c command.h diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 8616555..0f63ad0 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,68 @@ +Sun Nov 15 09:22:09 1992 Fred Fish (fnf@cygnus.com) + + * Makefile.in (SFILES_MAINDIR): Add ch-exp.y. + * Makefile.in (YYFILES): Add ch-exp.tab.c. + * Makefile.in (YYOBJ): Add ch-exp.tab.o. + * Makefile.in (saber_gdb): Add unload of ch-exp.y and load + of ch-exp.tab.c. + * Makefile.in (distclean): Add target ch-exp.tab.c. + * Makefile.in (realclean): Add rm of ch-exp.tab.c. + * Makefile.in (c-exp.tab.c, m2-exp.tab.c): Add dependency on + Makefile since it contains sed patterns used in generation. + Add sed pattern to also delete #include of any malloc.h. + * Makefile.in (ch-exp.tab.o, ch-exp.tab.c): New targets. + * ch-exp.y: New expression parser, for GNU-Chill. + * c-exp.y, expr.c, expression.h, language.c, m2-exp.y, + parser-defs.h, valarith.c, valops.c, value.h: Remap macros and + function names to conform to K&R terminology with respect to + logical and bitwise operators: + UNOP_ZEROP => UNOP_LOGICAL_NOT + UNOP_LOGNOT => UNOP_COMPLEMENT + BINOP_LOGAND => BINOP_BITWISE_AND + BINOP_LOGXOR => BINOP_BITWISE_XOR + BINOP_LOGIOR => BINOP_BITWISE_IOR + BINOP_AND => BINOP_LOGICAL_AND + BINOP_OR => BINOP_LOGICAL_OR + PREC_OR => PREC_LOGICAL_OR + PREC_AND => PREC_LOGICAL_AND + PREC_LOGIOR => PREC_BITWISE_IOR + PREC_LOGXOR => PREC_BITWISE_XOR + PREC_LOGAND => PREC_BITWISE_AND + value_zerop() => value_logical_not() + value_lognot() => value_complement() + * c-exp.y (c_op_print_tab): Add explicit empty terminator. + * m2-exp.y (m2_op_print_tab): Add explicit empty terminator. + * defs.h (enum language): Add language_chill. + * dwarfread.c (set_cu_language): Add LANG_CHILL case and make + LANG_MODULA2 a recognized language. + * eval.c (evaluate_subexp): Add OP_BOOL case. + * expprint.c (print_subexp): Add OP_BOOL case. + * gdbtypes.h (enum_typecode): Note TYPE_CODE_BOOL used for + Chill as well as Modula-2. + * gdbtypes.y (builtin_type_chill_bool, builtin_type_chill_long, + builtin_type_chill_ulong, builtin_type_chill_real): Add. + * i387-tdep.c (sys/dir.h): Remove, appears to be unnecessary + and is nonexistant in some SVR4 based systems. + * language.c (DEFAULT_ALLOCSIZE): Change from 3 => 4. + * language.c (set_language_command): Add chill. + * language.c (binop_result_type, integral_type, character_type, + boolean_type, structured_type, value_true, binop_type_check): + Add language_chill cases. + * language.h (_LANG_chill): Define. + * m2-exp.y (number_sign, modblock): Make static, #ifdef out + unused modblock. + * m2-exp.y (ANDAND): Rename to LOGICAL_AND. + * source.c (source_info): Fix minor nits, print "1 line" rather + than "1 lines", and "language is ". + * symfile.c (deduce_language_from_filename): Recognize the + filename extensions ".chill", ".c186", and ".c286" for Chill. + * valarith.c (value_binop): Handle TYPE_CODE_BOOL as well + as TYPE_CODE_INT and TYPE_CODE_FLOAT. + * valprint.c (val_print): Print TYPE_CODE_BOOL type values as + "TRUE" or "FALSE". + * valprint.c (typedef_print): Add case for language_chill. + * values.c (value_from_longest): Handle TYPE_CODE_BOOL. + Fri Nov 13 20:24:10 1992 Stu Grossman (grossman at cygnus.com) * infcmd.c (step_over_calls): Improve comments. diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 1758173..1cfbcdb 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -201,7 +201,7 @@ SFILES_MAINDIR = \ mem-break.c target.c \ dbxread.c coffread.c elfread.c dwarfread.c xcoffread.c stabsread.c \ ieee-float.c language.c parse.c buildsym.c objfiles.c \ - minsyms.c mipsread.c maint.c + minsyms.c mipsread.c maint.c ch-exp.y # Source files in subdirectories (which will be handled separately by # 'make gdb.tar.Z'). @@ -325,8 +325,8 @@ NTSSTART = kdb-start.o SUBDIRS = doc # For now, shortcut the "configure GDB for fewer languages" stuff. -YYFILES = c-exp.tab.c m2-exp.tab.c -YYOBJ = c-exp.tab.o m2-exp.tab.o +YYFILES = c-exp.tab.c m2-exp.tab.c ch-exp.tab.c +YYOBJ = c-exp.tab.o m2-exp.tab.o ch-exp.tab.o # Prevent Sun make from putting in the machine type. Setting # TARGET_ARCH to nothing works for SunOS 3, 4.0, but not for 4.1. @@ -372,8 +372,9 @@ saber_gdb: $(SFILES) $(DEPFILES) copying.c version.c #setopt load_flags $(CFLAGS) -I$(BFD_DIR) -DHOST_SYS=SUN4_SYS #load ./init.c $(SFILES) #unload ${srcdir}/c-exp.y ${srcdir}/m2-exp.y ${srcdir}/vx-share/*.h + #unload ${srcdir}/ch-exp.y #unload ${srcdir}/nindy-share/[A-Z]* - #load c-exp.tab.c m2-exp.tab.c + #load c-exp.tab.c m2-exp.tab.c ch-exp.tab.c #load copying.c version.c #load ../opcodes/libopcodes.a #load ../libiberty/libiberty.a @@ -623,14 +624,14 @@ clean: rm -f gdb[0-9] @$(MAKE) subdir_do DO=clean "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) -distclean: clean c-exp.tab.c m2-exp.tab.c TAGS +distclean: clean c-exp.tab.c m2-exp.tab.c ch-exp.tab.c TAGS rm -f tm.h xm.h config.status rm -f y.output yacc.acts yacc.tmp rm -f ${TESTS} Makefile depend @$(MAKE) subdir_do DO=distclean "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) realclean: clean - rm -f c-exp.tab.c m2-exp.tab.c TAGS + rm -f c-exp.tab.c m2-exp.tab.c ch-exp.tab.c TAGS rm -f tm.h xm.h config.status rm -f Makefile depend @$(MAKE) subdir_do DO=realclean "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) @@ -687,25 +688,46 @@ version.c: Makefile # Remove bogus decls for malloc/realloc/free which conflict with everything # else. c-exp.tab.o: c-exp.tab.c -c-exp.tab.c: $(srcdir)/c-exp.y +c-exp.tab.c: $(srcdir)/c-exp.y Makefile @echo 'Expect 4 shift/reduce conflicts.' ${YACC} $(srcdir)/c-exp.y -sed -e '/extern.*malloc/d' \ -e '/extern.*realloc/d' \ -e '/extern.*free/d' \ + -e '/include.*malloc.h/d' \ -e 's/malloc/xmalloc/g' \ -e 's/realloc/xrealloc/g' \ < y.tab.c > c-exp.tab.c -rm y.tab.c +# ch-exp.tab.c is generated in target dir from ch-exp.y if it doesn't exist +# in srcdir, then compiled in target dir to ch-exp.tab.o. +# Remove bogus decls for malloc/realloc/free which conflict with everything +# else. +ch-exp.tab.o: ch-exp.tab.c +ch-exp.tab.c: $(srcdir)/ch-exp.y Makefile + @echo 'Expect 4 shift/reduce conflicts.' + ${YACC} $(srcdir)/ch-exp.y + -sed -e '/extern.*malloc/d' \ + -e '/extern.*realloc/d' \ + -e '/extern.*free/d' \ + -e '/include.*malloc.h/d' \ + -e 's/malloc/xmalloc/g' \ + -e 's/realloc/xrealloc/g' \ + < y.tab.c > ch-exp.tab.c + -rm y.tab.c + # m2-exp.tab.c is generated in target dir from m2-exp.y if it doesn't exist # in srcdir, then compiled in target dir to m2-exp.tab.o. +# Remove bogus decls for malloc/realloc/free which conflict with everything +# else. m2-exp.tab.o: m2-exp.tab.c -m2-exp.tab.c: $(srcdir)/m2-exp.y +m2-exp.tab.c: $(srcdir)/m2-exp.y Makefile ${YACC} $(srcdir)/m2-exp.y -sed -e '/extern.*malloc/d' \ -e '/extern.*realloc/d' \ -e '/extern.*free/d' \ + -e '/include.*malloc.h/d' \ -e 's/malloc/xmalloc/g' \ -e 's/realloc/xrealloc/g' \ < y.tab.c > m2-exp.tab.c diff --git a/gdb/c-exp.y b/gdb/c-exp.y index 8184f3d..c9258a0 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -234,11 +234,11 @@ exp : '-' exp %prec UNARY ; exp : '!' exp %prec UNARY - { write_exp_elt_opcode (UNOP_ZEROP); } + { write_exp_elt_opcode (UNOP_LOGICAL_NOT); } ; exp : '~' exp %prec UNARY - { write_exp_elt_opcode (UNOP_LOGNOT); } + { write_exp_elt_opcode (UNOP_COMPLEMENT); } ; exp : INCREMENT exp %prec UNARY @@ -396,23 +396,23 @@ exp : exp '>' exp ; exp : exp '&' exp - { write_exp_elt_opcode (BINOP_LOGAND); } + { write_exp_elt_opcode (BINOP_BITWISE_AND); } ; exp : exp '^' exp - { write_exp_elt_opcode (BINOP_LOGXOR); } + { write_exp_elt_opcode (BINOP_BITWISE_XOR); } ; exp : exp '|' exp - { write_exp_elt_opcode (BINOP_LOGIOR); } + { write_exp_elt_opcode (BINOP_BITWISE_IOR); } ; exp : exp ANDAND exp - { write_exp_elt_opcode (BINOP_AND); } + { write_exp_elt_opcode (BINOP_LOGICAL_AND); } ; exp : exp OROR exp - { write_exp_elt_opcode (BINOP_OR); } + { write_exp_elt_opcode (BINOP_LOGICAL_OR); } ; exp : exp '?' exp ':' exp %prec '?' @@ -1057,9 +1057,9 @@ const static struct token tokentab2[] = {"*=", ASSIGN_MODIFY, BINOP_MUL}, {"/=", ASSIGN_MODIFY, BINOP_DIV}, {"%=", ASSIGN_MODIFY, BINOP_REM}, - {"|=", ASSIGN_MODIFY, BINOP_LOGIOR}, - {"&=", ASSIGN_MODIFY, BINOP_LOGAND}, - {"^=", ASSIGN_MODIFY, BINOP_LOGXOR}, + {"|=", ASSIGN_MODIFY, BINOP_BITWISE_IOR}, + {"&=", ASSIGN_MODIFY, BINOP_BITWISE_AND}, + {"^=", ASSIGN_MODIFY, BINOP_BITWISE_XOR}, {"++", INCREMENT, BINOP_END}, {"--", DECREMENT, BINOP_END}, {"->", ARROW, BINOP_END}, @@ -1478,11 +1478,11 @@ const static struct op_print c_op_print_tab[] = { {",", BINOP_COMMA, PREC_COMMA, 0}, {"=", BINOP_ASSIGN, PREC_ASSIGN, 1}, - {"||", BINOP_OR, PREC_OR, 0}, - {"&&", BINOP_AND, PREC_AND, 0}, - {"|", BINOP_LOGIOR, PREC_LOGIOR, 0}, - {"&", BINOP_LOGAND, PREC_LOGAND, 0}, - {"^", BINOP_LOGXOR, PREC_LOGXOR, 0}, + {"||", BINOP_LOGICAL_OR, PREC_LOGICAL_OR, 0}, + {"&&", BINOP_LOGICAL_AND, PREC_LOGICAL_AND, 0}, + {"|", BINOP_BITWISE_IOR, PREC_BITWISE_IOR, 0}, + {"^", BINOP_BITWISE_XOR, PREC_BITWISE_XOR, 0}, + {"&", BINOP_BITWISE_AND, PREC_BITWISE_AND, 0}, {"==", BINOP_EQUAL, PREC_EQUAL, 0}, {"!=", BINOP_NOTEQUAL, PREC_EQUAL, 0}, {"<=", BINOP_LEQ, PREC_ORDER, 0}, @@ -1498,8 +1498,8 @@ const static struct op_print c_op_print_tab[] = {"%", BINOP_REM, PREC_MUL, 0}, {"@", BINOP_REPEAT, PREC_REPEAT, 0}, {"-", UNOP_NEG, PREC_PREFIX, 0}, - {"!", UNOP_ZEROP, PREC_PREFIX, 0}, - {"~", UNOP_LOGNOT, PREC_PREFIX, 0}, + {"!", UNOP_LOGICAL_NOT, PREC_PREFIX, 0}, + {"~", UNOP_COMPLEMENT, PREC_PREFIX, 0}, {"*", UNOP_IND, PREC_PREFIX, 0}, {"&", UNOP_ADDR, PREC_PREFIX, 0}, {"sizeof ", UNOP_SIZEOF, PREC_PREFIX, 0}, @@ -1507,6 +1507,7 @@ const static struct op_print c_op_print_tab[] = {"--", UNOP_PREDECREMENT, PREC_PREFIX, 0}, /* C++ */ {"::", BINOP_SCOPE, PREC_PREFIX, 0}, + {NULL, 0, 0, 0} }; /* These variables point to the objects diff --git a/gdb/ch-exp.y b/gdb/ch-exp.y new file mode 100644 index 0000000..9812fc7 --- /dev/null +++ b/gdb/ch-exp.y @@ -0,0 +1,1199 @@ +/* YACC grammar for Chill expressions, for GDB. + Copyright (C) 1992 Free Software Foundation, Inc. + +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 2 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, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* Parse a Chill 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 ( and for example) just became + too messy, particularly when such includes can be inserted at random + times by the parser generator. + + Also note that the language accepted by this parser is more liberal + than the one accepted by an actual Chill compiler. For example, the + language rule that a simple name string can not be one of the reserved + simple name strings is not enforced (e.g "case" is not treated as a + reserved name). Another example is that Chill is a strongly typed + language, and certain expressions that violate the type constraints + may still be evaluated if gdb can do so in a meaningful manner, while + such expressions would be rejected by the compiler. The reason for + this more liberal behavior is the philosophy that the debugger + is intended to be a tool that is used by the programmer when things + go wrong, and as such, it should provide as few artificial barriers + to it's use as possible. If it can do something meaningful, even + something that violates language contraints that are enforced by the + compiler, it should do so without complaint. + + */ + +%{ + +#include +#include +#include "defs.h" +#include "symtab.h" +#include "gdbtypes.h" +#include "frame.h" +#include "expression.h" +#include "language.h" +#include "value.h" +#include "parser-defs.h" +#include "bfd.h" +#include "symfile.h" +#include "objfiles.h" + +/* These MUST be included in any grammar file!!!! Please choose unique names! + Note that this are a combined list of variables that can be produced + by any one of bison, byacc, or yacc. */ +#define yymaxdepth chill_maxdepth +#define yyparse chill_parse +#define yylex chill_lex +#define yyerror chill_error +#define yylval chill_lval +#define yychar chill_char +#define yydebug chill_debug +#define yypact chill_pact +#define yyr1 chill_r1 +#define yyr2 chill_r2 +#define yydef chill_def +#define yychk chill_chk +#define yypgo chill_pgo +#define yyact chill_act +#define yyexca chill_exca +#define yyerrflag chill_errflag +#define yynerrs chill_nerrs +#define yyps chill_ps +#define yypv chill_pv +#define yys chill_s +#define yy_yys chill_yys +#define yystate chill_state +#define yytmp chill_tmp +#define yyv chill_v +#define yy_yyv chill_yyv +#define yyval chill_val +#define yylloc chill_lloc +#define yyss chill_yyss /* byacc */ +#define yyssp chill_yysp /* byacc */ +#define yyvs chill_yyvs /* byacc */ +#define yyvsp chill_yyvsp /* byacc */ + +static int +yylex PARAMS ((void)); + +static void +yyerror PARAMS ((char *)); + +int +yyparse PARAMS ((void)); + +/* #define YYDEBUG 1 */ + +%} + +/* 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; + unsigned LONGEST ulval; + struct { + LONGEST val; + struct type *type; + } typed_val; + double dval; + struct symbol *sym; + struct type *tval; + struct stoken sval; + struct ttype tsym; + struct symtoken ssym; + int voidval; + struct block *bval; + enum exp_opcode opcode; + struct internalvar *ivar; + + struct type **tvec; + int *ivec; + } + +%{ +static int parse_number PARAMS ((void)); +%} + +%token FIXME + +%token INTEGER_LITERAL +%token BOOLEAN_LITERAL +%token CHARACTER_LITERAL +%token SET_LITERAL +%token EMPTINESS_LITERAL +%token CHARACTER_STRING_LITERAL +%token BIT_STRING_LITERAL + +%token STRING +%token CONSTANT +%token '.' +%token ';' +%token ':' +%token CASE +%token OF +%token ESAC +%token LOGIOR +%token ORIF +%token LOGXOR +%token LOGAND +%token ANDIF +%token '=' +%token NOTEQUAL +%token '>' +%token GTR +%token '<' +%token LEQ +%token IN +%token '+' +%token '-' +%token '*' +%token '/' +%token SLASH_SLASH +%token MOD +%token REM +%token NOT +%token POINTER +%token RECEIVE +%token SC +%token '[' +%token ']' +%token '(' +%token ')' +%token UP +%token IF +%token THEN +%token ELSE +%token FI +%token ELSIF +%token ILLEGAL_TOKEN + +%type location +%type primitive_value +%type location_contents +%type value_name +%type literal +%type tuple +%type value_string_element +%type value_string_slice +%type value_array_element +%type value_array_slice +%type value_structure_field +%type expression_conversion +%type value_procedure_call +%type value_built_in_routine_call +%type start_expression +%type zero_adic_operator +%type parenthesised_expression +%type value +%type undefined_value +%type expression +%type conditional_expression +%type then_alternative +%type else_alternative +%type sub_expression +%type value_case_alternative +%type operand_0 +%type operand_1 +%type operand_2 +%type operand_3 +%type operand_4 +%type operand_5 +%type operand_6 +%type integer_literal_expression +%type synonym_name +%type value_enumeration_name +%type value_do_with_name +%type value_receive_name +%type general_procedure_name +%type string_primitive_value +%type start_element +%type left_element +%type right_element +%type slice_size +%type array_primitive_value +%type expression_list +%type lower_element +%type upper_element +%type first_element +%type structure_primitive_value +%type field_name +%type mode_name +%type boolean_expression +%type case_selector_list +%type subexpression +%type case_label_specification +%type buffer_location + +%% + +/* Z.200, 5.3.1 */ + +value : expression + { + $$ = 0; /* FIXME */ + } + | undefined_value + { + $$ = 0; /* FIXME */ + } + ; + +undefined_value : FIXME + { + $$ = 0; /* FIXME */ + } + ; + +/* Z.200, 4.2.1 */ + +location : FIXME + { + $$ = 0; /* FIXME */ + } + ; + +/* Z.200, 5.2.1 */ + +primitive_value : location_contents + { + $$ = 0; /* FIXME */ + } + | value_name + { + $$ = 0; /* FIXME */ + } + | literal + { + $$ = 0; /* FIXME */ + } + | tuple + { + $$ = 0; /* FIXME */ + } + | value_string_element + { + $$ = 0; /* FIXME */ + } + | value_string_slice + { + $$ = 0; /* FIXME */ + } + | value_array_element + { + $$ = 0; /* FIXME */ + } + | value_array_slice + { + $$ = 0; /* FIXME */ + } + | value_structure_field + { + $$ = 0; /* FIXME */ + } + | expression_conversion + { + $$ = 0; /* FIXME */ + } + | value_procedure_call + { + $$ = 0; /* FIXME */ + } + | value_built_in_routine_call + { + $$ = 0; /* FIXME */ + } + | start_expression + { + $$ = 0; /* FIXME */ + } + | zero_adic_operator + { + $$ = 0; /* FIXME */ + } + | parenthesised_expression + { + $$ = 0; /* FIXME */ + } + ; + +/* Z.200, 5.2.2 */ + +location_contents: location + { + $$ = 0; /* FIXME */ + } + ; + +/* Z.200, 5.2.3 */ + +value_name : synonym_name + { + $$ = 0; /* FIXME */ + } + | value_enumeration_name + { + $$ = 0; /* FIXME */ + } + | value_do_with_name + { + $$ = 0; /* FIXME */ + } + | value_receive_name + { + $$ = 0; /* FIXME */ + } + | general_procedure_name + { + $$ = 0; /* FIXME */ + } + ; + +/* Z.200, 5.2.4.1 */ + +literal : INTEGER_LITERAL + { + write_exp_elt_opcode (OP_LONG); + write_exp_elt_type ($1.type); + write_exp_elt_longcst ((LONGEST) ($1.val)); + write_exp_elt_opcode (OP_LONG); + } + | BOOLEAN_LITERAL + { + write_exp_elt_opcode (OP_BOOL); + write_exp_elt_longcst ((LONGEST) $1); + write_exp_elt_opcode (OP_BOOL); + } + | CHARACTER_LITERAL + { + $$ = 0; /* FIXME */ + } + | SET_LITERAL + { + $$ = 0; /* FIXME */ + } + | EMPTINESS_LITERAL + { + $$ = 0; /* FIXME */ + } + | CHARACTER_STRING_LITERAL + { + $$ = 0; /* FIXME */ + } + | BIT_STRING_LITERAL + { + $$ = 0; /* FIXME */ + } + ; + +/* Z.200, 5.2.5 */ + +tuple : FIXME + { + $$ = 0; /* FIXME */ + } + ; + + +/* Z.200, 5.2.6 */ + +value_string_element: string_primitive_value '(' start_element ')' + { + $$ = 0; /* FIXME */ + } + ; + +/* Z.200, 5.2.7 */ + +value_string_slice: string_primitive_value '(' left_element ':' right_element ')' + { + $$ = 0; /* FIXME */ + } + | string_primitive_value '(' start_element UP slice_size ')' + { + $$ = 0; /* FIXME */ + } + ; + +/* Z.200, 5.2.8 */ + +value_array_element: array_primitive_value '(' expression_list ')' + { + $$ = 0; /* FIXME */ + } + ; + +/* Z.200, 5.2.9 */ + +value_array_slice: array_primitive_value '(' lower_element ':' upper_element ')' + { + $$ = 0; /* FIXME */ + } + | array_primitive_value '(' first_element UP slice_size '(' + { + $$ = 0; /* FIXME */ + } + ; + +/* Z.200, 5.2.10 */ + +value_structure_field: structure_primitive_value '.' field_name + { + $$ = 0; /* FIXME */ + } + ; + +/* Z.200, 5.2.11 */ + +expression_conversion: mode_name '(' expression ')' + { + $$ = 0; /* FIXME */ + } + ; + +/* Z.200, 5.2.12 */ + +value_procedure_call: FIXME + { + $$ = 0; /* FIXME */ + } + ; + +/* Z.200, 5.2.13 */ + +value_built_in_routine_call: FIXME + { + $$ = 0; /* FIXME */ + } + ; + +/* Z.200, 5.2.14 */ + +start_expression: FIXME + { + $$ = 0; /* FIXME */ + } /* Not in GNU-Chill */ + ; + +/* Z.200, 5.2.15 */ + +zero_adic_operator: FIXME + { + $$ = 0; /* FIXME */ + } + ; + +/* Z.200, 5.2.16 */ + +parenthesised_expression: '(' expression ')' + { + $$ = 0; /* FIXME */ + } + ; + +/* Z.200, 5.3.2 */ + +expression : operand_0 + { + $$ = 0; /* FIXME */ + } + | conditional_expression + { + $$ = 0; /* FIXME */ + } + ; + +conditional_expression : IF boolean_expression then_alternative else_alternative FI + { + $$ = 0; /* FIXME */ + } + | CASE case_selector_list OF value_case_alternative '[' ELSE sub_expression ']' ESAC + { + $$ = 0; /* FIXME */ + } + ; + +then_alternative: THEN subexpression + { + $$ = 0; /* FIXME */ + } + ; + +else_alternative: ELSE subexpression + { + $$ = 0; /* FIXME */ + } + | ELSIF boolean_expression then_alternative else_alternative + { + $$ = 0; /* FIXME */ + } + ; + +sub_expression : expression + { + $$ = 0; /* FIXME */ + } + ; + +value_case_alternative: case_label_specification ':' sub_expression ';' + { + $$ = 0; /* FIXME */ + } + ; + +/* Z.200, 5.3.3 */ + +operand_0 : operand_1 + { + $$ = 0; /* FIXME */ + } + | operand_0 LOGIOR operand_1 + { + write_exp_elt_opcode (BINOP_BITWISE_IOR); + } + | operand_0 ORIF operand_1 + { + $$ = 0; /* FIXME */ + } + | operand_0 LOGXOR operand_1 + { + write_exp_elt_opcode (BINOP_BITWISE_XOR); + } + ; + +/* Z.200, 5.3.4 */ + +operand_1 : operand_2 + { + $$ = 0; /* FIXME */ + } + | operand_1 LOGAND operand_2 + { + write_exp_elt_opcode (BINOP_BITWISE_AND); + } + | operand_1 ANDIF operand_2 + { + $$ = 0; /* FIXME */ + } + ; + +/* Z.200, 5.3.5 */ + +operand_2 : operand_3 + { + $$ = 0; /* FIXME */ + } + | operand_2 '=' operand_3 + { + write_exp_elt_opcode (BINOP_EQUAL); + } + | operand_2 NOTEQUAL operand_3 + { + write_exp_elt_opcode (BINOP_NOTEQUAL); + } + | operand_2 '>' operand_3 + { + write_exp_elt_opcode (BINOP_GTR); + } + | operand_2 GTR operand_3 + { + write_exp_elt_opcode (BINOP_GEQ); + } + | operand_2 '<' operand_3 + { + write_exp_elt_opcode (BINOP_LESS); + } + | operand_2 LEQ operand_3 + { + write_exp_elt_opcode (BINOP_LEQ); + } + | operand_2 IN operand_3 + { + $$ = 0; /* FIXME */ + } + ; + + +/* Z.200, 5.3.6 */ + +operand_3 : operand_4 + { + $$ = 0; /* FIXME */ + } + | operand_3 '+' operand_4 + { + write_exp_elt_opcode (BINOP_ADD); + } + | operand_3 '-' operand_4 + { + write_exp_elt_opcode (BINOP_SUB); + } + | operand_3 SLASH_SLASH operand_4 + { + $$ = 0; /* FIXME */ + } + ; + +/* Z.200, 5.3.7 */ + +operand_4 : operand_5 + { + $$ = 0; /* FIXME */ + } + | operand_4 '*' operand_5 + { + write_exp_elt_opcode (BINOP_MUL); + } + | operand_4 '/' operand_5 + { + write_exp_elt_opcode (BINOP_DIV); + } + | operand_4 MOD operand_5 + { + $$ = 0; /* FIXME */ + } + | operand_4 REM operand_5 + { + $$ = 0; /* FIXME */ + } + ; + +/* Z.200, 5.3.8 */ + +operand_5 : operand_6 + { + $$ = 0; /* FIXME */ + } + | '-' operand_6 + { + write_exp_elt_opcode (UNOP_NEG); + } + | NOT operand_6 + { + write_exp_elt_opcode (UNOP_LOGICAL_NOT); + } + | '(' integer_literal_expression ')' operand_6 + { + $$ = 0; /* FIXME */ + } + ; + +/* Z.200, 5.3.9 */ + +operand_6 : POINTER location + { + $$ = 0; /* FIXME */ + } + | RECEIVE buffer_location + { + $$ = 0; /* FIXME */ + } + | primitive_value + { + $$ = 0; /* FIXME */ + } + ; + + +/* Z.200, 12.4.3 */ +/* FIXME: For now we just accept only a single integer literal. */ + +integer_literal_expression: + INTEGER_LITERAL + { + $$ = 0; + } + +/* Things which still need productions... */ +synonym_name : FIXME { $$ = 0; } +value_enumeration_name : FIXME { $$ = 0; } +value_do_with_name : FIXME { $$ = 0; } +value_receive_name : FIXME { $$ = 0; } +general_procedure_name : FIXME { $$ = 0; } +string_primitive_value : FIXME { $$ = 0; } +start_element : FIXME { $$ = 0; } +left_element : FIXME { $$ = 0; } +right_element : FIXME { $$ = 0; } +slice_size : FIXME { $$ = 0; } +array_primitive_value : FIXME { $$ = 0; } +expression_list : FIXME { $$ = 0; } +lower_element : FIXME { $$ = 0; } +upper_element : FIXME { $$ = 0; } +first_element : FIXME { $$ = 0; } +structure_primitive_value: FIXME { $$ = 0; } +field_name : FIXME { $$ = 0; } +mode_name : FIXME { $$ = 0; } +boolean_expression : FIXME { $$ = 0; } +case_selector_list : FIXME { $$ = 0; } +subexpression : FIXME { $$ = 0; } +case_label_specification: FIXME { $$ = 0; } +buffer_location : FIXME { $$ = 0; } + +%% + +/* Recognize a character literal. */ + +static int +decode_character_literal () +{ + char *tokptr = lexptr; + int ival = 0; + + if (*tokptr++ != '\'') + { + return (0); + } + + if (*tokptr != '\\') + { + ival = *++tokptr; + tokptr++; + } + else + { + + } + if (*++tokptr != '\'') + { + return (0); + } + yylval.typed_val.val = ival; + yylval.typed_val.type = builtin_type_int; + lexptr = tokptr; + return (CHARACTER_LITERAL); +} + +/* Recognize an integer literal, as specified in Z.200 sec 5.2.4.2. + Note that according to 5.2.4.2, a single "_" is also a valid integer + literal, however GNU-chill requires there to be at least one "digit" + in any integer literal. */ + +static int +decode_integer_literal () +{ + char *tokptr = lexptr; + int ival = 0; + int base = 0; + int digits = 0; + int temp; + + /* Look for an explicit base specifier, which is optional. */ + + switch (*tokptr) + { + case 'd': + case 'D': + base = 10; + tokptr++; + break; + case 'b': + case 'B': + base = 2; + tokptr++; + break; + case 'h': + case 'H': + base = 16; + tokptr++; + break; + case 'o': + case 'O': + base = 8; + tokptr++; + break; + } + + /* If we found no explicit base then default to 10, otherwise ensure + that the character after the explicit base is a single quote. */ + + if (base == 0) + { + base = 10; + } + else + { + if (*tokptr++ != '\'') + { + return (0); + } + } + + /* Start looking for a value composed of valid digits as set by the base + in use. Note that '_' characters are valid anywhere, in any quantity, + and are simply ignored. Since we must find at least one valid digit, + or reject this token as an integer literal, we keep track of how many + digits we have encountered. */ + + while (*tokptr != '\0') + { + temp = tolower (*tokptr); + tokptr++; + switch (temp) + { + case '_': + continue; + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + temp -= '0'; + break; + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': + temp -= 'a'; + temp += 10; + break; + default: + temp = base; + break; + } + if (temp < base) + { + digits++; + ival *= base; + ival += temp; + } + else + { + /* Found something not in domain for current base. */ + tokptr--; /* Unconsume what gave us indigestion. */ + break; + } + } + + /* If we didn't find any digits, then we don't have a valid integer + literal, so reject the entire token. Otherwise, set up the parser + variables, advance the current lexical scan pointer, and return the + INTEGER_LITERAL token. */ + + if (digits == 0) + { + return (0); + } + else + { + yylval.typed_val.val = ival; + yylval.typed_val.type = builtin_type_int; + lexptr = tokptr; + return (INTEGER_LITERAL); + } +} + +static void convert_float () +{ +#if 0 + extern double strtod (); + double d; + char tmp[256]; + char *p = yytext, *p1 = tmp; + char c; + + while (c = *p++) + { + switch (c) + { + case '_': + break; + case 'E': + case 'd': + case 'D': + *p1++ = 'e'; + break; + default: + *p1++ = c; + break; + } + } + *p1 = '\0'; + d = strtod (tmp, &p1); + if (*p1) + { + /* add error handling here */ + ; + } + yylval.dval = d; +#endif +} + +/* 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. */ + +/*** Needs some error checking for the float case ***/ + +static int +parse_number () +{ +} + +struct token +{ + char *operator; + int token; +}; + +const static struct token tokentab5[] = +{ + { "ANDIF", ANDIF } +}; + +const static struct token tokentab4[] = +{ + { "ORIF", ORIF } +}; + +const static struct token tokentab3[] = +{ + { "NOT", NOT }, + { "XOR", LOGXOR }, + { "AND", LOGAND } +}; + +const static struct token tokentab2[] = +{ + { "//", SLASH_SLASH }, + { "/=", NOTEQUAL }, + { "<=", LEQ }, + { ">=", GTR }, + { "IN", IN }, + { "OR", LOGIOR } +}; + +/* Read one token, getting characters through lexptr. */ +/* This is where we will check to make sure that the language and the + operators used are compatible. */ + +static int +yylex () +{ + unsigned int i; + int token; + + /* Skip over any leading whitespace. */ + while (isspace (*lexptr)) + { + lexptr++; + } + /* Look for special single character cases which can't be the first + character of some other multicharacter token. */ + switch (*lexptr) + { + case '\0': + return (0); + case '.': + case '=': + case ':': + case ';': + case '!': + case '+': + case '-': + case '*': + case '/': + case '(': + case ')': + case '[': + case ']': + return (*lexptr++); + } + /* Look for characters which start a particular kind of multicharacter + token, such as a character literal. */ + switch (*lexptr) + { + case '\'': + if ((token = decode_character_literal ()) != 0) + { + return (token); + } + break; + } + /* See if it is a special token of length 5. */ + for (i = 0; i < sizeof (tokentab5) / sizeof (tokentab5[0]); i++) + { + if (strncmp (lexptr, tokentab5[i].operator, 5) == 0) + { + lexptr += 5; + return (tokentab5[i].token); + } + } + /* See if it is a special token of length 4. */ + for (i = 0; i < sizeof (tokentab4) / sizeof (tokentab4[0]); i++) + { + if (strncmp (lexptr, tokentab4[i].operator, 4) == 0) + { + lexptr += 4; + return (tokentab4[i].token); + } + } + /* See if it is a special token of length 3. */ + for (i = 0; i < sizeof (tokentab3) / sizeof (tokentab3[0]); i++) + { + if (strncmp (lexptr, tokentab3[i].operator, 3) == 0) + { + lexptr += 3; + 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 (lexptr, tokentab2[i].operator, 2) == 0) + { + lexptr += 2; + return (tokentab2[i].token); + } + } + /* Look for single character cases which which could be the first + character of some other multicharacter token, but aren't, or we + would already have found it. */ + switch (*lexptr) + { + case '/': + case '<': + case '>': + return (*lexptr++); + } + /* Look for other special tokens. */ + if (strncmp (lexptr, "TRUE", 4) == 0) /* FIXME: What about lowercase? */ + { + yylval.ulval = 1; + lexptr += 4; + return (BOOLEAN_LITERAL); + } + if (strncmp (lexptr, "FALSE", 5) == 0) /* FIXME: What about lowercase? */ + { + yylval.ulval = 0; + lexptr += 5; + return (BOOLEAN_LITERAL); + } + if ((token = decode_integer_literal ()) != 0) + { + return (token); + } + return (ILLEGAL_TOKEN); +} + +static void +yyerror (msg) + char *msg; /* unused */ +{ + printf ("Parsing: %s\n", lexptr); + if (yychar < 256) + { + error ("Invalid syntax in expression near character '%c'.", yychar); + } + else + { + error ("Invalid syntax in expression"); + } +} + + +/* Table of operators and their precedences for printing expressions. */ + +const static struct op_print chill_op_print_tab[] = { + {"AND", BINOP_LOGICAL_AND, PREC_LOGICAL_AND, 0}, + {"OR", BINOP_LOGICAL_OR, PREC_LOGICAL_OR, 0}, + {"NOT", UNOP_LOGICAL_NOT, PREC_PREFIX, 0}, + {"MOD", BINOP_REM, PREC_MUL, 0}, + {":=", BINOP_ASSIGN, PREC_ASSIGN, 1}, + {"=", BINOP_EQUAL, PREC_EQUAL, 0}, + {"/=", BINOP_NOTEQUAL, PREC_EQUAL, 0}, + {"<=", BINOP_LEQ, PREC_ORDER, 0}, + {">=", BINOP_GEQ, PREC_ORDER, 0}, + {">", BINOP_GTR, PREC_ORDER, 0}, + {"<", BINOP_LESS, PREC_ORDER, 0}, + {"+", BINOP_ADD, PREC_ADD, 0}, + {"-", BINOP_SUB, PREC_ADD, 0}, + {"*", BINOP_MUL, PREC_MUL, 0}, + {"/", BINOP_DIV, PREC_MUL, 0}, + {"-", UNOP_NEG, PREC_PREFIX, 0}, + {NULL, 0, 0, 0} +}; + + +/* The built-in types of Chill. */ + +struct type *builtin_type_chill_bool; +struct type *builtin_type_chill_long; +struct type *builtin_type_chill_ulong; +struct type *builtin_type_chill_real; + +struct type ** const (chill_builtin_types[]) = +{ + &builtin_type_chill_bool, + &builtin_type_chill_long, + &builtin_type_chill_ulong, + &builtin_type_chill_real, + 0 +}; + +const struct language_defn chill_language_defn = { + "chill", + language_chill, + chill_builtin_types, + range_check_on, + type_check_on, + chill_parse, /* parser */ + chill_error, /* parser error function */ + &BUILTIN_TYPE_LONGEST, /* longest signed integral type */ + &BUILTIN_TYPE_UNSIGNED_LONGEST,/* longest unsigned integral type */ + &builtin_type_chill_real, /* longest floating point type */ + "0x%x", "0x%", "x", /* Hex format, prefix, suffix */ + "0%o", "0%", "o", /* Octal format, prefix, suffix */ + chill_op_print_tab, /* expression operators for printing */ + LANG_MAGIC +}; + +/* Initialization for Chill */ + +void +_initialize_chill_exp () +{ + builtin_type_chill_bool = + init_type (TYPE_CODE_BOOL, TARGET_INT_BIT / TARGET_CHAR_BIT, + TYPE_FLAG_UNSIGNED, + "BOOL", (struct objfile *) NULL); + builtin_type_chill_long = + init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT, + 0, + "LONG", (struct objfile *) NULL); + builtin_type_chill_ulong = + init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT, + TYPE_FLAG_UNSIGNED, + "ULONG", (struct objfile *) NULL); + builtin_type_chill_real = + init_type (TYPE_CODE_FLT, TARGET_DOUBLE_BIT / TARGET_CHAR_BIT, + 0, + "LONG_REAL", (struct objfile *) NULL); + + add_language (&chill_language_defn); +} diff --git a/gdb/defs.h b/gdb/defs.h index ce26e75..2ec8a0c 100644 --- a/gdb/defs.h +++ b/gdb/defs.h @@ -47,8 +47,11 @@ quit PARAMS ((void)); #define QUIT { if (quit_flag) quit (); } -/* Notes on classes: class_alias is for alias commands which are not - abbreviations of the original command. */ +/* Command classes are top-level categories into which commands are broken + down for "help" purposes. + Notes on classes: class_alias is for alias commands which are not + abbreviations of the original command. class-pseudo is for commands + which are not really commands nor help topics ("stop"). */ enum command_class { @@ -57,7 +60,8 @@ enum command_class /* Classes of commands */ no_class = -1, class_run = 0, class_vars, class_stack, class_files, class_support, class_info, class_breakpoint, - class_alias, class_obscure, class_user, class_maintenance + class_alias, class_obscure, class_user, class_maintenance, + class_pseudo }; /* the cleanup list records things that have to be undone @@ -338,6 +342,7 @@ enum language language_auto, /* Placeholder for automatic setting */ language_c, /* C */ language_cplus, /* C++ */ + language_chill, /* Chill */ language_m2 /* Modula-2 */ }; @@ -368,6 +373,11 @@ local_hex_string_custom PARAMS ((int, char *)); /* language.c */ #include "xm.h" +/* Native machine support. This will be a symlink to one of the + nm-*.h files, built by the `configure' script. */ + +#include "nm.h" + /* If the xm.h file did not define the mode string used to open the files, assume that binary files are opened the same way as text files */ @@ -811,6 +821,4 @@ push_word (); #define MAINTENANCE_CMDS 1 #endif -#include "energize.h" - #endif /* !defined (DEFS_H) */ diff --git a/gdb/dwarfread.c b/gdb/dwarfread.c index 85b626c..d9bd3f4 100644 --- a/gdb/dwarfread.c +++ b/gdb/dwarfread.c @@ -486,13 +486,18 @@ set_cu_language (dip) case LANG_C_PLUS_PLUS: cu_language = language_cplus; break; + case LANG_CHILL: + cu_language = language_chill; + break; + case LANG_MODULA2: + cu_language = language_m2; + break; case LANG_ADA83: case LANG_COBOL74: case LANG_COBOL85: case LANG_FORTRAN77: case LANG_FORTRAN90: case LANG_PASCAL83: - case LANG_MODULA2: default: cu_language = language_unknown; break; diff --git a/gdb/eval.c b/gdb/eval.c index 55fca20..82e02ce 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -237,6 +237,11 @@ evaluate_subexp (expect_type, exp, pos, noside) (*pos) += 2; return value_of_register (longest_to_int (exp->elts[pc + 1].longconst)); + case OP_BOOL: + (*pos) += 2; + return value_from_longest (builtin_type_chill_bool, + exp->elts[pc + 1].longconst); + case OP_INTERNALVAR: (*pos) += 2; return value_of_internalvar (exp->elts[pc + 1].internalvar); @@ -252,7 +257,7 @@ evaluate_subexp (expect_type, exp, pos, noside) case TERNOP_COND: /* Skip third and second args to evaluate the first one. */ arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); - if (value_zerop (arg1)) + if (value_logical_not (arg1)) { evaluate_subexp (NULL_TYPE, exp, pos, EVAL_SKIP); return evaluate_subexp (NULL_TYPE, exp, pos, noside); @@ -342,9 +347,8 @@ evaluate_subexp (expect_type, exp, pos, noside) nargs = longest_to_int (exp->elts[pc + 1].longconst) + 1; /* First, evaluate the structure into arg2 */ pc2 = (*pos)++; - /* type = exp->elts[pc2 + 1].type; */ - tem2 = strlen (&exp->elts[pc2 + 2].string); - *pos += 3 + (tem2 + sizeof (union exp_element)) / sizeof (union exp_element); + tem2 = strlen (&exp->elts[pc2 + 1].string); + *pos += 2 + (tem2 + sizeof (union exp_element)) / sizeof (union exp_element); if (noside == EVAL_SKIP) goto nosideret; @@ -377,13 +381,9 @@ evaluate_subexp (expect_type, exp, pos, noside) int static_memfuncp; value temp = arg2; - /* argvec[0] gets the method; - argvec[1] gets the 'this' pointer (unless static) (from arg2); - the remaining args go into the rest of argvec. */ - argvec[1] = arg2; argvec[0] = - value_struct_elt (&temp, argvec+1, &exp->elts[pc2 + 2].string, + value_struct_elt (&temp, argvec+1, &exp->elts[pc2 + 1].string, &static_memfuncp, op == STRUCTOP_STRUCT ? "structure" : "structure pointer"); @@ -428,50 +428,40 @@ evaluate_subexp (expect_type, exp, pos, noside) return call_function_by_hand (argvec[0], nargs, argvec + 1); case STRUCTOP_STRUCT: - tem = strlen (&exp->elts[pc + 2].string); - (*pos) += 3 + ((tem + sizeof (union exp_element)) + tem = strlen (&exp->elts[pc + 1].string); + (*pos) += 2 + ((tem + sizeof (union exp_element)) / sizeof (union exp_element)); arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); - if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_PTR) - goto handle_structop_ptr; - type = exp->elts[pc + 1].type; - if (type) - arg1 = value_ind (value_cast (lookup_pointer_type (type), - value_addr (arg1))); if (noside == EVAL_SKIP) goto nosideret; if (noside == EVAL_AVOID_SIDE_EFFECTS) return value_zero (lookup_struct_elt_type (VALUE_TYPE (arg1), - &exp->elts[pc + 2].string, + &exp->elts[pc + 1].string, 0), lval_memory); else { value temp = arg1; - return value_struct_elt (&temp, (value *)0, &exp->elts[pc + 2].string, + return value_struct_elt (&temp, (value *)0, &exp->elts[pc + 1].string, (int *) 0, "structure"); } case STRUCTOP_PTR: - tem = strlen (&exp->elts[pc + 2].string); - (*pos) += 3 + (tem + sizeof (union exp_element)) / sizeof (union exp_element); + tem = strlen (&exp->elts[pc + 1].string); + (*pos) += 2 + (tem + sizeof (union exp_element)) / sizeof (union exp_element); arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); - handle_structop_ptr: - type = exp->elts[pc + 1].type; - if (type) - arg1 = value_cast (lookup_pointer_type (type), arg1); if (noside == EVAL_SKIP) goto nosideret; if (noside == EVAL_AVOID_SIDE_EFFECTS) return value_zero (lookup_struct_elt_type (TYPE_TARGET_TYPE (VALUE_TYPE (arg1)), - &exp->elts[pc + 2].string, + &exp->elts[pc + 1].string, 0), lval_memory); else { value temp = arg1; - return value_struct_elt (&temp, (value *)0, &exp->elts[pc + 2].string, + return value_struct_elt (&temp, (value *)0, &exp->elts[pc + 1].string, (int *) 0, "structure pointer"); } @@ -552,9 +542,9 @@ evaluate_subexp (expect_type, exp, pos, noside) case BINOP_REM: case BINOP_LSH: case BINOP_RSH: - case BINOP_LOGAND: - case BINOP_LOGIOR: - case BINOP_LOGXOR: + case BINOP_BITWISE_AND: + case BINOP_BITWISE_IOR: + case BINOP_BITWISE_XOR: arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside); if (noside == EVAL_SKIP) @@ -592,7 +582,7 @@ evaluate_subexp (expect_type, exp, pos, noside) else return value_subscript (arg1, arg2); - case BINOP_AND: + case BINOP_LOGICAL_AND: arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); if (noside == EVAL_SKIP) { @@ -611,14 +601,14 @@ evaluate_subexp (expect_type, exp, pos, noside) } else { - tem = value_zerop (arg1); + tem = value_logical_not (arg1); arg2 = evaluate_subexp (NULL_TYPE, exp, pos, (tem ? EVAL_SKIP : noside)); return value_from_longest (builtin_type_int, - (LONGEST) (!tem && !value_zerop (arg2))); + (LONGEST) (!tem && !value_logical_not (arg2))); } - case BINOP_OR: + case BINOP_LOGICAL_OR: arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); if (noside == EVAL_SKIP) { @@ -637,11 +627,11 @@ evaluate_subexp (expect_type, exp, pos, noside) } else { - tem = value_zerop (arg1); + tem = value_logical_not (arg1); arg2 = evaluate_subexp (NULL_TYPE, exp, pos, (!tem ? EVAL_SKIP : noside)); return value_from_longest (builtin_type_int, - (LONGEST) (!tem || !value_zerop (arg2))); + (LONGEST) (!tem || !value_logical_not (arg2))); } case BINOP_EQUAL: @@ -760,19 +750,19 @@ evaluate_subexp (expect_type, exp, pos, noside) else return value_neg (arg1); - case UNOP_LOGNOT: + case UNOP_COMPLEMENT: /* C++: check for and handle destructor names. */ op = exp->elts[*pos].opcode; arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); if (noside == EVAL_SKIP) goto nosideret; - if (unop_user_defined_p (UNOP_LOGNOT, arg1)) - return value_x_unop (arg1, UNOP_LOGNOT); + if (unop_user_defined_p (UNOP_COMPLEMENT, arg1)) + return value_x_unop (arg1, UNOP_COMPLEMENT); else - return value_lognot (arg1); + return value_complement (arg1); - case UNOP_ZEROP: + case UNOP_LOGICAL_NOT: arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); if (noside == EVAL_SKIP) goto nosideret; @@ -780,7 +770,7 @@ evaluate_subexp (expect_type, exp, pos, noside) return value_x_unop (arg1, op); else return value_from_longest (builtin_type_int, - (LONGEST) value_zerop (arg1)); + (LONGEST) value_logical_not (arg1)); case UNOP_IND: if (expect_type && TYPE_CODE (expect_type) == TYPE_CODE_PTR) diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 95f4035..23c4644 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -80,7 +80,7 @@ enum type_code /* Modula-2 */ TYPE_CODE_CHAR, /* *real* character type */ - TYPE_CODE_BOOL /* Builtin Modula-2 BOOLEAN */ + TYPE_CODE_BOOL /* Builtin Modula-2/Chill BOOLEAN */ }; /* For now allow source to use TYPE_CODE_CLASS for C++ classes, as an @@ -489,6 +489,13 @@ extern struct type *builtin_type_m2_card; extern struct type *builtin_type_m2_real; extern struct type *builtin_type_m2_bool; +/* Chill types */ + +extern struct type *builtin_type_chill_bool; +extern struct type *builtin_type_chill_long; +extern struct type *builtin_type_chill_ulong; +extern struct type *builtin_type_chill_real; + /* LONG_LONG is defined if the host has "long long". */ #ifdef LONG_LONG diff --git a/gdb/i387-tdep.c b/gdb/i387-tdep.c index 1d801fa..a93052d 100644 --- a/gdb/i387-tdep.c +++ b/gdb/i387-tdep.c @@ -29,7 +29,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #endif #include -#include #include #include #include diff --git a/gdb/language.c b/gdb/language.c index e835445..0fb0796 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -112,7 +112,7 @@ const struct language_defn *expected_language; static const struct language_defn **languages; static unsigned languages_size; static unsigned languages_allocsize; -#define DEFAULT_ALLOCSIZE 3 +#define DEFAULT_ALLOCSIZE 4 /* The "set language/type/range" commands all put stuff in these buffers. This is to make them work as set/show commands. The @@ -165,6 +165,7 @@ set_language_command (ignore, from_tty) local or auto Automatic setting based on source file\n\ c Use the C language\n\ c++ Use the C++ language\n\ +chill Use the Chill language\n\ modula-2 Use the Modula-2 language\n"); /* Restore the silly string. */ set_language(current_language->la_language); @@ -457,6 +458,8 @@ binop_result_type(v1,v2) not needed. */ return l1 > l2 ? VALUE_TYPE(v1) : VALUE_TYPE(v2); break; + case language_chill: + error ("Missing Chill support in function binop_result_check.");/*FIXME*/ } abort(); return (struct type *)0; /* For lint */ @@ -605,6 +608,8 @@ integral_type (type) (TYPE_CODE(type) != TYPE_CODE_ENUM) ? 0 : 1; case language_m2: return TYPE_CODE(type) != TYPE_CODE_INT ? 0 : 1; + case language_chill: + error ("Missing Chill support in function integral_type."); /*FIXME*/ default: error ("Language not supported."); } @@ -640,6 +645,8 @@ character_type (type) return (TYPE_CODE(type) == TYPE_CODE_INT) && TYPE_LENGTH(type) == sizeof(char) ? 1 : 0; + case language_chill: + error ("Missing Chill support in function character_type."); /*FIXME*/ default: return (0); } @@ -652,6 +659,7 @@ boolean_type (type) { switch(current_language->la_language) { + case language_chill: case language_m2: return TYPE_CODE(type) != TYPE_CODE_BOOL ? 0 : 1; @@ -696,6 +704,8 @@ structured_type(type) return (TYPE_CODE(type) == TYPE_CODE_STRUCT) || (TYPE_CODE(type) == TYPE_CODE_SET) || (TYPE_CODE(type) == TYPE_CODE_ARRAY); + case language_chill: + error ("Missing Chill support in function structured_type."); /*FIXME*/ default: return (0); } @@ -717,7 +727,7 @@ value_true(val) case language_c: case language_cplus: - return !value_zerop (val); + return !value_logical_not (val); case language_m2: type = VALUE_TYPE(val); @@ -740,6 +750,9 @@ value_true(val) return 0; /* BOOLEAN with value FALSE */ break; + case language_chill: + error ("Missing Chill support in function value_type."); /*FIXME*/ + default: error ("Language not supported."); } @@ -786,8 +799,8 @@ binop_type_check(arg1,arg2,op) type_op_error ("Arguments to %s must be of the same type.",op); break; - case BINOP_AND: - case BINOP_OR: + case BINOP_LOGICAL_AND: + case BINOP_LOGICAL_OR: if (!boolean_type(t1) || !boolean_type(t2)) type_op_error ("Arguments to %s must be of boolean type.",op); break; @@ -839,7 +852,7 @@ binop_type_check(arg1,arg2,op) /* Unary checks -- arg2 is null */ - case UNOP_ZEROP: + case UNOP_LOGICAL_NOT: if (!boolean_type(t1)) type_op_error ("Argument to %s must be of boolean type.",op); break; @@ -900,6 +913,12 @@ binop_type_check(arg1,arg2,op) break; } #endif + +#ifdef _LANG_chill + case language_chill: + error ("Missing Chill support in function binop_type_check.");/*FIXME*/ +#endif + } } } diff --git a/gdb/language.h b/gdb/language.h index 95eef2b..9fd39b2 100644 --- a/gdb/language.h +++ b/gdb/language.h @@ -32,6 +32,7 @@ struct value; /* #include "lang_def.h" */ #define _LANG_c #define _LANG_m2 +#define _LANG_chill /* range_mode == range_mode_auto: range_check set automatically to default of language. diff --git a/gdb/m2-exp.y b/gdb/m2-exp.y index d932e16..3f83323 100644 --- a/gdb/m2-exp.y +++ b/gdb/m2-exp.y @@ -105,11 +105,13 @@ int yyparse PARAMS ((void)); /* The sign of the number being parsed. */ -int number_sign = 1; +static int number_sign = 1; /* The block that the module specified by the qualifer on an identifer is contained in, */ -struct block *modblock=0; +#if 0 +static struct block *modblock=0; +#endif /* #define YYDEBUG 1 */ %} @@ -174,7 +176,7 @@ struct block *modblock=0; %nonassoc ASSIGN %left '<' '>' LEQ GEQ '=' NOTEQUAL '#' IN %left OROR -%left ANDAND '&' +%left LOGICAL_AND '&' %left '@' %left '+' '-' %left '*' '/' DIV MOD @@ -217,7 +219,7 @@ exp : '+' exp %prec UNARY ; exp : not_exp exp %prec UNARY - { write_exp_elt_opcode (UNOP_ZEROP); } + { write_exp_elt_opcode (UNOP_LOGICAL_NOT); } ; not_exp : NOT @@ -444,16 +446,12 @@ exp : exp '>' exp { write_exp_elt_opcode (BINOP_GTR); } ; -exp : exp ANDAND exp - { write_exp_elt_opcode (BINOP_AND); } - ; - -exp : exp '&' exp - { write_exp_elt_opcode (BINOP_AND); } +exp : exp LOGICAL_AND exp + { write_exp_elt_opcode (BINOP_LOGICAL_AND); } ; exp : exp OROR exp - { write_exp_elt_opcode (BINOP_OR); } + { write_exp_elt_opcode (BINOP_LOGICAL_OR); } ; exp : exp ASSIGN exp @@ -813,7 +811,7 @@ static struct keyword keytab[] = { {"OR" , OROR }, {"IN", IN },/* Note space after IN */ - {"AND", ANDAND }, + {"AND", LOGICAL_AND}, {"ABS", ABS }, {"CHR", CHR }, {"DEC", DEC }, @@ -1189,9 +1187,9 @@ const static struct op_print m2_op_print_tab[] = { {"DIV", BINOP_INTDIV, PREC_MUL, 0}, {"MOD", BINOP_REM, PREC_MUL, 0}, {":=", BINOP_ASSIGN, PREC_ASSIGN, 1}, - {"OR", BINOP_OR, PREC_OR, 0}, - {"AND", BINOP_AND, PREC_AND, 0}, - {"NOT", UNOP_ZEROP, PREC_PREFIX, 0}, + {"OR", BINOP_LOGICAL_OR, PREC_LOGICAL_OR, 0}, + {"AND", BINOP_LOGICAL_AND, PREC_LOGICAL_AND, 0}, + {"NOT", UNOP_LOGICAL_NOT, PREC_PREFIX, 0}, {"=", BINOP_EQUAL, PREC_EQUAL, 0}, {"<>", BINOP_NOTEQUAL, PREC_EQUAL, 0}, {"<=", BINOP_LEQ, PREC_ORDER, 0}, @@ -1200,6 +1198,7 @@ const static struct op_print m2_op_print_tab[] = { {"<", BINOP_LESS, PREC_ORDER, 0}, {"^", UNOP_IND, PREC_PREFIX, 0}, {"@", BINOP_REPEAT, PREC_REPEAT, 0}, + {NULL, 0, 0, 0} }; /* The built-in types of Modula-2. */ diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h index b32e3c1..8de2c83 100644 --- a/gdb/parser-defs.h +++ b/gdb/parser-defs.h @@ -175,9 +175,9 @@ int comma_terminates; they are used as the "surrounding precedence" to force various kinds of things to be parenthesized. */ enum precedence -{ PREC_NULL, PREC_COMMA, PREC_ABOVE_COMMA, PREC_ASSIGN, PREC_OR, PREC_AND, - PREC_LOGIOR, PREC_LOGAND, PREC_LOGXOR, PREC_EQUAL, PREC_ORDER, - PREC_SHIFT, PREC_ADD, PREC_MUL, PREC_REPEAT, +{ PREC_NULL, PREC_COMMA, PREC_ABOVE_COMMA, PREC_ASSIGN, PREC_LOGICAL_OR, + PREC_LOGICAL_AND, PREC_BITWISE_IOR, PREC_BITWISE_AND, PREC_BITWISE_XOR, + PREC_EQUAL, PREC_ORDER, PREC_SHIFT, PREC_ADD, PREC_MUL, PREC_REPEAT, PREC_HYPER, PREC_PREFIX, PREC_SUFFIX }; /* Table mapping opcodes into strings for printing operators diff --git a/gdb/symfile.c b/gdb/symfile.c index 21ead48..96c994f 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -29,6 +29,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "objfiles.h" #include "gdbcmd.h" #include "breakpoint.h" +#include "language.h" #include #include @@ -50,6 +51,9 @@ extern int info_verbose; /* Functions this file defines */ static void +set_initial_language PARAMS ((void)); + +static void load_command PARAMS ((char *, int)); static void @@ -643,7 +647,7 @@ symbol_file_command (args, from_tty) current_source_line = 0; if (from_tty) { - printf_filtered ("No symbol file now.\n"); + printf ("No symbol file now.\n"); } } else @@ -681,11 +685,45 @@ symbol_file_command (args, from_tty) else { symbol_file_add (name, from_tty, (CORE_ADDR)0, 1, mapped, readnow); + set_initial_language (); } do_cleanups (cleanups); } } +/* Set the initial language. + + A better solution would be to record the language in the psymtab when reading + partial symbols, and then use it (if known) to set the language. This would + be a win for formats that encode the language in an easily discoverable place, + such as DWARF. For stabs, we can jump through hoops looking for specially + named symbols or try to intuit the language from the specific type of stabs + we find, but we can't do that until later when we read in full symbols. + FIXME. */ + +static void +set_initial_language () +{ + struct partial_symtab *pst; + enum language lang = language_unknown; + + pst = find_main_psymtab (); + if (pst != NULL) + { + if (pst -> filename != NULL) + { + lang = deduce_language_from_filename (pst -> filename); + } + if (lang == language_unknown) + { + /* Make C the default language */ + lang = language_c; + } + set_language (lang); + expected_language = current_language; /* Don't warn the user */ + } +} + /* Open file specified by NAME and hand it off to BFD for preliminary analysis. Result is a newly initialized bfd *, which includes a newly malloc'd` copy of NAME (tilde-expanded and made absolute). @@ -720,6 +758,7 @@ symfile_bfd_open (name) error ("\"%s\": can't open to read symbols: %s.", name, bfd_errmsg (bfd_error)); } + sym_bfd->cacheable = true; if (!bfd_check_format (sym_bfd, bfd_object)) { @@ -1013,6 +1052,8 @@ deduce_language_from_filename (filename) return language_c; else if(!strcmp(c,".cc") || !strcmp(c,".C")) return language_cplus; + else if(!strcmp(c,".chill") || !strcmp(c,".c186") || !strcmp(c,".c286")) + return language_chill; return language_unknown; /* default */ } @@ -1128,7 +1169,7 @@ clear_symtab_users_once () return; clear_symtab_users_done = clear_symtab_users_queued; - printf_filtered ("Resetting debugger state after updating old symbol tables\n"); + printf ("Resetting debugger state after updating old symbol tables\n"); /* Someday, we should do better than this, by only blowing away the things that really need to be blown. */ diff --git a/gdb/valarith.c b/gdb/valarith.c index 4c0706b..7db4681 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -134,8 +134,7 @@ value_subscripted_rvalue (array, idx) error ("no such vector element"); v = allocate_value (elt_type); - (void) memcpy (VALUE_CONTENTS (v), VALUE_CONTENTS (array) + elt_offs, - elt_size); + memcpy (VALUE_CONTENTS (v), VALUE_CONTENTS (array) + elt_offs, elt_size); if (VALUE_LVAL (array) == lval_internalvar) VALUE_LVAL (v) = lval_internalvar_component; @@ -225,32 +224,32 @@ value_x_binop (arg1, arg2, op, otherop) ptr = tstr+8; switch (op) { - case BINOP_ADD: strcpy(ptr,"+"); break; - case BINOP_SUB: strcpy(ptr,"-"); break; - case BINOP_MUL: strcpy(ptr,"*"); break; - case BINOP_DIV: strcpy(ptr,"/"); break; - case BINOP_REM: strcpy(ptr,"%"); break; - case BINOP_LSH: strcpy(ptr,"<<"); break; - case BINOP_RSH: strcpy(ptr,">>"); break; - case BINOP_LOGAND: strcpy(ptr,"&"); break; - case BINOP_LOGIOR: strcpy(ptr,"|"); break; - case BINOP_LOGXOR: strcpy(ptr,"^"); break; - case BINOP_AND: strcpy(ptr,"&&"); break; - case BINOP_OR: strcpy(ptr,"||"); break; - case BINOP_MIN: strcpy(ptr,"?"); break; - case BINOP_ASSIGN: strcpy(ptr,"="); break; + case BINOP_ADD: strcpy(ptr,"+"); break; + case BINOP_SUB: strcpy(ptr,"-"); break; + case BINOP_MUL: strcpy(ptr,"*"); break; + case BINOP_DIV: strcpy(ptr,"/"); break; + case BINOP_REM: strcpy(ptr,"%"); break; + case BINOP_LSH: strcpy(ptr,"<<"); break; + case BINOP_RSH: strcpy(ptr,">>"); break; + case BINOP_BITWISE_AND: strcpy(ptr,"&"); break; + case BINOP_BITWISE_IOR: strcpy(ptr,"|"); break; + case BINOP_BITWISE_XOR: strcpy(ptr,"^"); break; + case BINOP_LOGICAL_AND: strcpy(ptr,"&&"); break; + case BINOP_LOGICAL_OR: strcpy(ptr,"||"); break; + case BINOP_MIN: strcpy(ptr,"?"); break; + case BINOP_ASSIGN: strcpy(ptr,"="); break; case BINOP_ASSIGN_MODIFY: switch (otherop) { - case BINOP_ADD: strcpy(ptr,"+="); break; - case BINOP_SUB: strcpy(ptr,"-="); break; - case BINOP_MUL: strcpy(ptr,"*="); break; - case BINOP_DIV: strcpy(ptr,"/="); break; - case BINOP_REM: strcpy(ptr,"%="); break; - case BINOP_LOGAND: strcpy(ptr,"&="); break; - case BINOP_LOGIOR: strcpy(ptr,"|="); break; - case BINOP_LOGXOR: strcpy(ptr,"^="); break; + case BINOP_ADD: strcpy(ptr,"+="); break; + case BINOP_SUB: strcpy(ptr,"-="); break; + case BINOP_MUL: strcpy(ptr,"*="); break; + case BINOP_DIV: strcpy(ptr,"/="); break; + case BINOP_REM: strcpy(ptr,"%="); break; + case BINOP_BITWISE_AND: strcpy(ptr,"&="); break; + case BINOP_BITWISE_IOR: strcpy(ptr,"|="); break; + case BINOP_BITWISE_XOR: strcpy(ptr,"^="); break; default: error ("Invalid binary operation specified."); } @@ -318,9 +317,9 @@ value_x_unop (arg1, op) case UNOP_PREDECREMENT: strcpy(ptr,"++"); break; case UNOP_POSTINCREMENT: strcpy(ptr,"++"); break; case UNOP_POSTDECREMENT: strcpy(ptr,"++"); break; - case UNOP_ZEROP: strcpy(ptr,"!"); break; - case UNOP_LOGNOT: strcpy(ptr,"~"); break; - case UNOP_NEG: strcpy(ptr,"-"); break; + case UNOP_LOGICAL_NOT: strcpy(ptr,"!"); break; + case UNOP_COMPLEMENT: strcpy(ptr,"~"); break; + case UNOP_NEG: strcpy(ptr,"-"); break; default: error ("Invalid binary operation specified."); } @@ -354,12 +353,16 @@ value_binop (arg1, arg2, op) if ((TYPE_CODE (VALUE_TYPE (arg1)) != TYPE_CODE_FLT && - TYPE_CODE (VALUE_TYPE (arg1)) != TYPE_CODE_INT) + TYPE_CODE (VALUE_TYPE (arg1)) != TYPE_CODE_INT + && + TYPE_CODE (VALUE_TYPE (arg1)) != TYPE_CODE_BOOL) || (TYPE_CODE (VALUE_TYPE (arg2)) != TYPE_CODE_FLT && - TYPE_CODE (VALUE_TYPE (arg2)) != TYPE_CODE_INT)) - error ("Argument to arithmetic operation not a number."); + TYPE_CODE (VALUE_TYPE (arg2)) != TYPE_CODE_INT + && + TYPE_CODE (VALUE_TYPE (arg2)) != TYPE_CODE_BOOL)) + error ("Argument to arithmetic operation not a number or boolean."); if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_FLT || @@ -394,8 +397,39 @@ value_binop (arg1, arg2, op) SWAP_TARGET_AND_HOST (&v, sizeof (v)); *(double *) VALUE_CONTENTS_RAW (val) = v; } + else if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_BOOL + && + TYPE_CODE (VALUE_TYPE (arg2)) == TYPE_CODE_BOOL) + { + LONGEST v1, v2, v; + v1 = value_as_long (arg1); + v2 = value_as_long (arg2); + + switch (op) + { + case BINOP_BITWISE_AND: + v = v1 & v2; + break; + + case BINOP_BITWISE_IOR: + v = v1 | v2; + break; + + case BINOP_BITWISE_XOR: + v = v1 ^ v2; + break; + + default: + error ("Invalid operation on booleans."); + } + + val = allocate_value (builtin_type_chill_bool); + SWAP_TARGET_AND_HOST (&v, sizeof (v)); + *(LONGEST *) VALUE_CONTENTS_RAW (val) = v; + } else /* Integral operations here. */ + /* FIXME: Also mixed integral/booleans, with result an integer. */ { /* Should we promote to unsigned longest? */ if ((TYPE_UNSIGNED (VALUE_TYPE (arg1)) @@ -437,23 +471,23 @@ value_binop (arg1, arg2, op) v = v1 >> v2; break; - case BINOP_LOGAND: + case BINOP_BITWISE_AND: v = v1 & v2; break; - case BINOP_LOGIOR: + case BINOP_BITWISE_IOR: v = v1 | v2; break; - case BINOP_LOGXOR: + case BINOP_BITWISE_XOR: v = v1 ^ v2; break; - case BINOP_AND: + case BINOP_LOGICAL_AND: v = v1 && v2; break; - case BINOP_OR: + case BINOP_LOGICAL_OR: v = v1 || v2; break; @@ -509,23 +543,23 @@ value_binop (arg1, arg2, op) v = v1 >> v2; break; - case BINOP_LOGAND: + case BINOP_BITWISE_AND: v = v1 & v2; break; - case BINOP_LOGIOR: + case BINOP_BITWISE_IOR: v = v1 | v2; break; - case BINOP_LOGXOR: + case BINOP_BITWISE_XOR: v = v1 ^ v2; break; - case BINOP_AND: + case BINOP_LOGICAL_AND: v = v1 && v2; break; - case BINOP_OR: + case BINOP_LOGICAL_OR: v = v1 || v2; break; @@ -553,7 +587,7 @@ value_binop (arg1, arg2, op) /* Simulate the C operator ! -- return 1 if ARG1 contains zero. */ int -value_zerop (arg1) +value_logical_not (arg1) value arg1; { register int len; @@ -696,7 +730,7 @@ value_neg (arg1) } value -value_lognot (arg1) +value_complement (arg1) register value arg1; { COERCE_ENUM (arg1); diff --git a/gdb/valprint.c b/gdb/valprint.c index 9170805..8811cc5 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -628,6 +628,7 @@ cplus_val_print (type, valaddr, stream, format, recurse, pretty, dont_print) obstack_ptr_grow (&dont_print_obstack, TYPE_BASECLASS (type, i)); } + /* Fix to use baseclass_offset instead. FIXME */ baddr = baseclass_addr (type, i, valaddr, 0, &err); if (err == 0 && baddr == 0) error ("could not find virtual baseclass `%s'\n", @@ -867,8 +868,9 @@ val_print (type, valaddr, address, stream, format, deref_ref, recurse, pretty) addr = unpack_pointer (lookup_pointer_type (builtin_type_void), valaddr); - if (addr < 128) /* FIXME! What is this 128? */ + if (METHOD_PTR_IS_VIRTUAL(addr)) { + int offset = METHOD_PTR_TO_VOFFSET(addr); len = TYPE_NFN_FIELDS (domain); for (i = 0; i < len; i++) { @@ -878,9 +880,9 @@ val_print (type, valaddr, address, stream, format, deref_ref, recurse, pretty) for (j = 0; j < len2; j++) { QUIT; - if (TYPE_FN_FIELD_VOFFSET (f, j) == addr) + if (TYPE_FN_FIELD_VOFFSET (f, j) == offset) { - kind = "virtual"; + kind = "virtual "; goto common; } } @@ -1283,6 +1285,11 @@ val_print (type, valaddr, address, stream, format, deref_ref, recurse, pretty) fprintf_filtered (stream, ""); break; + case TYPE_CODE_BOOL: + val = unpack_long (builtin_type_chill_bool, valaddr); + fprintf_filtered (stream, val ? "TRUE" : "FALSE"); + break; + default: error ("Invalid type code in symbol table."); } @@ -1324,6 +1331,10 @@ typedef_print (type, new, stream) type_print(type,"",stream,0); break; #endif +#ifdef _LANG_chill + case language_chill: + error("Missing Chill support in function typedef_print."); /*FIXME*/ +#endif default: error("Language not supported."); } @@ -1862,8 +1873,13 @@ type_print_base (type, stream, show, level) fprintf_filtered (stream, ";\n"); } - /* C++: print out the methods */ + /* If there are both fields and methods, put a space between. */ len = TYPE_NFN_FIELDS (type); + if (len && section_type != s_none) + fprintf_filtered (stream, "\n"); + + /* C++: print out the methods */ + for (i = 0; i < len; i++) { struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i); diff --git a/gdb/values.c b/gdb/values.c index aaff4126..61a1614 100644 --- a/gdb/values.c +++ b/gdb/values.c @@ -1384,7 +1384,7 @@ value_from_longest (type, num) integers, and that all pointers have the same form. */ if (code == TYPE_CODE_INT || code == TYPE_CODE_ENUM || code == TYPE_CODE_CHAR || code == TYPE_CODE_PTR || - code == TYPE_CODE_REF) + code == TYPE_CODE_REF || code == TYPE_CODE_BOOL) { if (len == sizeof (char)) * (char *) VALUE_CONTENTS_RAW (val) = num; -- cgit v1.1