diff -rup ../../gdb-public.0/gdb/Makefile.in ./Makefile.in --- ../../gdb-public.0/gdb/Makefile.in 2007-10-28 18:33:03.000000000 -0400 +++ ./Makefile.in 2007-10-28 19:35:43.000000000 -0400 @@ -1870,7 +1870,7 @@ avr-tdep.o: avr-tdep.c $(defs_h) $(frame ax-gdb.o: ax-gdb.c $(defs_h) $(symtab_h) $(symfile_h) $(gdbtypes_h) \ $(value_h) $(expression_h) $(command_h) $(gdbcmd_h) $(frame_h) \ $(target_h) $(ax_h) $(ax_gdb_h) $(gdb_string_h) $(block_h) \ - $(regcache_h) + $(regcache_h) $(language_h) ax-general.o: ax-general.c $(defs_h) $(ax_h) $(value_h) $(gdb_string_h) bcache.o: bcache.c $(defs_h) $(gdb_obstack_h) $(bcache_h) $(gdb_string_h) \ $(gdb_assert_h) @@ -2889,7 +2889,7 @@ win32-nat.o: win32-nat.c $(defs_h) $(fra $(xml_support_h) $(i386_cygwin_tdep_h) win32-termcap.o: win32-termcap.c wrapper.o: wrapper.c $(defs_h) $(value_h) $(exceptions_h) $(wrapper_h) \ - $(ui_out_h) + $(ui_out_h) $(language_h) xcoffread.o: xcoffread.c $(defs_h) $(bfd_h) $(gdb_string_h) $(gdb_stat_h) \ $(coff_internal_h) $(libcoff_h) $(coff_xcoff_h) $(libxcoff_h) \ $(coff_rs6000_h) $(symtab_h) $(gdbtypes_h) $(symfile_h) \ @@ -3152,7 +3152,7 @@ mi-main.o: $(srcdir)/mi/mi-main.c $(defs $(gdb_string_h) $(exceptions_h) $(top_h) $(gdbthread_h) $(mi_cmds_h) \ $(mi_parse_h) $(mi_getopt_h) $(mi_console_h) $(ui_out_h) $(mi_out_h) \ $(interps_h) $(event_loop_h) $(event_top_h) $(gdbcore_h) $(value_h) \ - $(regcache_h) $(gdb_h) $(frame_h) $(mi_main_h) + $(regcache_h) $(gdb_h) $(frame_h) $(mi_main_h) $(language_h) $(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-main.c mi-out.o: $(srcdir)/mi/mi-out.c $(defs_h) $(ui_out_h) $(mi_out_h) $(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-out.c diff -rup ../../gdb-public.0/gdb/ada-lang.c ./ada-lang.c --- ../../gdb-public.0/gdb/ada-lang.c 2007-10-28 18:33:03.000000000 -0400 +++ ./ada-lang.c 2007-10-28 19:35:43.000000000 -0400 @@ -9677,7 +9677,8 @@ static struct expression * ada_parse_catchpoint_condition (char *cond_string, struct symtab_and_line sal) { - return (parse_exp_1 (&cond_string, block_for_pc (sal.pc), 0)); + return (parse_exp_1 (&cond_string, block_for_pc (sal.pc), 0, + curr_language ())); } /* Return the symtab_and_line that should be used to insert an exception diff -rup ../../gdb-public.0/gdb/ax-gdb.c ./ax-gdb.c --- ../../gdb-public.0/gdb/ax-gdb.c 2007-10-28 18:33:03.000000000 -0400 +++ ./ax-gdb.c 2007-10-28 19:35:43.000000000 -0400 @@ -33,6 +33,7 @@ #include "gdb_string.h" #include "block.h" #include "regcache.h" +#include "language.h" /* To make sense of this file, you should read doc/agentexpr.texi. Then look at the types and enums in ax-gdb.h. For the code itself, @@ -1786,7 +1787,7 @@ agent_command (char *exp, int from_tty) if (exp == 0) error_no_arg (_("expression to translate")); - expr = parse_expression (exp); + expr = parse_expression (exp, current_language); old_chain = make_cleanup (free_current_contents, &expr); agent = gen_trace_for_expr (get_frame_pc (fi), expr); make_cleanup_free_agent_expr (agent); diff -rup ../../gdb-public.0/gdb/breakpoint.c ./breakpoint.c --- ../../gdb-public.0/gdb/breakpoint.c 2007-10-28 18:33:03.000000000 -0400 +++ ./breakpoint.c 2007-10-28 19:40:08.000000000 -0400 @@ -599,7 +599,8 @@ condition_command (char *arg, int from_t for (loc = b->loc; loc; loc = loc->next) { arg = p; - loc->cond = parse_exp_1 (&arg, block_for_pc (loc->address), 0); + loc->cond = parse_exp_1 (&arg, block_for_pc (loc->address), 0, + language_def (b->language)); if (*arg) error (_("Junk at end of expression")); } @@ -5219,7 +5220,8 @@ create_breakpoint (struct symtabs_and_li if (b->cond_string) { char *arg = b->cond_string; - loc->cond = parse_exp_1 (&arg, block_for_pc (loc->address), 0); + loc->cond = parse_exp_1 (&arg, block_for_pc (loc->address), 0, + language_def (b->language)); if (*arg) { if (pending_bp) @@ -5526,7 +5528,7 @@ find_condition_and_thread (char *tok, CO if (toklen >= 1 && strncmp (tok, "if", toklen) == 0) { tok = cond_start = end_tok + 1; - parse_exp_1 (&tok, block_for_pc (pc), 0); + parse_exp_1 (&tok, block_for_pc (pc), 0, curr_language ()); cond_end = tok; *cond_string = savestring (cond_start, cond_end - cond_start); @@ -6018,7 +6020,7 @@ watch_command_1 (char *arg, int accessfl /* Parse arguments. */ innermost_block = NULL; exp_start = arg; - exp = parse_exp_1 (&arg, 0, 0); + exp = parse_exp_1 (&arg, 0, 0, curr_language ()); exp_end = arg; exp_valid_block = innermost_block; mark = value_mark (); @@ -6039,7 +6041,7 @@ watch_command_1 (char *arg, int accessfl if (toklen >= 1 && strncmp (tok, "if", toklen) == 0) { tok = cond_start = end_tok + 1; - cond = parse_exp_1 (&tok, 0, 0); + cond = parse_exp_1 (&tok, 0, 0, curr_language ()); cond_end = tok; } if (*tok) @@ -7532,7 +7534,7 @@ update_breakpoint_locations (struct brea TRY_CATCH (e, RETURN_MASK_ERROR) { new_loc->cond = parse_exp_1 (&s, block_for_pc (sals.sals[i].pc), - 0); + 0, language_def (b->language)); } if (e.reason < 0) { @@ -7703,7 +7705,7 @@ breakpoint_re_set_one (void *bint) parse_expression. */ b->exp = NULL; } - b->exp = parse_expression (b->exp_string); + b->exp = parse_expression (b->exp_string, language_def (b->language)); b->exp_valid_block = innermost_block; mark = value_mark (); if (b->val) @@ -7728,7 +7730,8 @@ breakpoint_re_set_one (void *bint) to parse_exp_1. */ b->loc->cond = NULL; } - b->loc->cond = parse_exp_1 (&s, (struct block *) 0, 0); + b->loc->cond = parse_exp_1 (&s, (struct block *) 0, 0, + language_def (b->language)); } if (breakpoint_enabled (b)) mention (b); diff -rup ../../gdb-public.0/gdb/cli/cli-script.c ./cli/cli-script.c --- ../../gdb-public.0/gdb/cli/cli-script.c 2007-10-28 18:33:03.000000000 -0400 +++ ./cli/cli-script.c 2007-10-28 19:35:43.000000000 -0400 @@ -414,7 +414,7 @@ execute_control_command (struct command_ if (!new_line) break; make_cleanup (free_current_contents, &new_line); - expr = parse_expression (new_line); + expr = parse_expression (new_line, current_language); make_cleanup (free_current_contents, &expr); ret = simple_control; @@ -481,7 +481,7 @@ execute_control_command (struct command_ break; make_cleanup (free_current_contents, &new_line); /* Parse the conditional for the if statement. */ - expr = parse_expression (new_line); + expr = parse_expression (new_line, current_language); make_cleanup (free_current_contents, &expr); current = NULL; diff -rup ../../gdb-public.0/gdb/eval.c ./eval.c --- ../../gdb-public.0/gdb/eval.c 2007-10-28 18:33:03.000000000 -0400 +++ ./eval.c 2007-10-28 19:35:43.000000000 -0400 @@ -82,7 +82,7 @@ evaluate_subexp (struct type *expect_typ CORE_ADDR parse_and_eval_address (char *exp) { - struct expression *expr = parse_expression (exp); + struct expression *expr = parse_expression (exp, curr_language ()); CORE_ADDR addr; struct cleanup *old_chain = make_cleanup (free_current_contents, &expr); @@ -98,7 +98,8 @@ parse_and_eval_address (char *exp) CORE_ADDR parse_and_eval_address_1 (char **expptr) { - struct expression *expr = parse_exp_1 (expptr, (struct block *) 0, 0); + struct expression *expr = parse_exp_1 (expptr, (struct block *) 0, 0, + curr_language ()); CORE_ADDR addr; struct cleanup *old_chain = make_cleanup (free_current_contents, &expr); @@ -113,7 +114,7 @@ parse_and_eval_address_1 (char **expptr) LONGEST parse_and_eval_long (char *exp) { - struct expression *expr = parse_expression (exp); + struct expression *expr = parse_expression (exp, curr_language ()); LONGEST retval; struct cleanup *old_chain = make_cleanup (free_current_contents, &expr); @@ -126,7 +127,7 @@ parse_and_eval_long (char *exp) struct value * parse_and_eval (char *exp) { - struct expression *expr = parse_expression (exp); + struct expression *expr = parse_expression (exp, curr_language ()); struct value *val; struct cleanup *old_chain = make_cleanup (free_current_contents, &expr); @@ -143,7 +144,8 @@ parse_and_eval (char *exp) struct value * parse_to_comma_and_eval (char **expp) { - struct expression *expr = parse_exp_1 (expp, (struct block *) 0, 1); + struct expression *expr = parse_exp_1 (expp, (struct block *) 0, 1, + curr_language ()); struct value *val; struct cleanup *old_chain = make_cleanup (free_current_contents, &expr); @@ -2297,7 +2299,7 @@ parse_and_eval_type (char *p, int length tmp[length + 1] = ')'; tmp[length + 2] = '0'; tmp[length + 3] = '\0'; - expr = parse_expression (tmp); + expr = parse_expression (tmp, curr_language ()); if (expr->elts[0].opcode != UNOP_CAST) error (_("Internal error in eval_type.")); return expr->elts[1].type; diff -rup ../../gdb-public.0/gdb/expression.h ./expression.h --- ../../gdb-public.0/gdb/expression.h 2007-10-28 18:33:03.000000000 -0400 +++ ./expression.h 2007-10-28 19:35:43.000000000 -0400 @@ -387,11 +387,14 @@ struct expression /* From parse.c */ -extern struct expression *parse_expression (char *); +extern struct expression *parse_expression (char *, + const struct language_defn *); -extern struct expression *parse_expression_in_context (char *, int); +extern struct expression *parse_expression_in_context + (char *, int, const struct language_defn *); -extern struct expression *parse_exp_1 (char **, struct block *, int); +extern struct expression *parse_exp_1 (char **, struct block *, int, + const struct language_defn *); /* The innermost context required by the stack and register variables we've encountered so far. To use this, set it to NULL, then call Only in .: gdb.ref diff -rup ../../gdb-public.0/gdb/language.c ./language.c --- ../../gdb-public.0/gdb/language.c 2007-10-28 18:33:03.000000000 -0400 +++ ./language.c 2007-10-28 19:35:43.000000000 -0400 @@ -354,6 +354,19 @@ set_case_command (char *ignore, int from show_case_command (NULL, from_tty, NULL, NULL); } +/* Just a function to be temporarily used in place of "current_language" + when we should in fact not rely on the global current language, but + have the language passed to us through the function arguments. + + Using this function allows us to be able to quickly grep for the + locations that need to be taken care of. */ + +const struct language_defn * +curr_language (void) +{ + return current_language; +} + /* Set the status of range and type checking and case sensitivity based on the current modes and the current language. If SHOW is non-zero, then print out the current language, diff -rup ../../gdb-public.0/gdb/language.h ./language.h --- ../../gdb-public.0/gdb/language.h 2007-10-28 18:33:03.000000000 -0400 +++ ./language.h 2007-10-28 19:35:43.000000000 -0400 @@ -311,6 +311,8 @@ struct language_defn extern const struct language_defn *current_language; +extern const struct language_defn *curr_language (void); + /* Pointer to the language_defn expected by the user, e.g. the language of main(), or the language we last mentioned in a message, or C. */ diff -rup ../../gdb-public.0/gdb/mi/mi-main.c ./mi/mi-main.c --- ../../gdb-public.0/gdb/mi/mi-main.c 2007-10-28 18:33:03.000000000 -0400 +++ ./mi/mi-main.c 2007-10-28 19:35:43.000000000 -0400 @@ -44,6 +44,7 @@ #include "gdb.h" #include "frame.h" #include "mi-main.h" +#include "language.h" #include #include @@ -693,7 +694,7 @@ mi_cmd_data_evaluate_expression (char *c return MI_CMD_ERROR; } - expr = parse_expression (argv[0]); + expr = parse_expression (argv[0], curr_language ()); old_chain = make_cleanup (free_current_contents, &expr); diff -rup ../../gdb-public.0/gdb/objc-lang.c ./objc-lang.c --- ../../gdb-public.0/gdb/objc-lang.c 2007-10-28 18:33:03.000000000 -0400 +++ ./objc-lang.c 2007-10-28 19:35:43.000000000 -0400 @@ -1520,7 +1520,7 @@ print_object_command (char *args, int fr "The 'print-object' command requires an argument (an Objective-C object)"); { - struct expression *expr = parse_expression (args); + struct expression *expr = parse_expression (args, current_language); struct cleanup *old_chain = make_cleanup (free_current_contents, &expr); int pc = 0; diff -rup ../../gdb-public.0/gdb/parse.c ./parse.c --- ../../gdb-public.0/gdb/parse.c 2007-10-28 18:33:03.000000000 -0400 +++ ./parse.c 2007-10-28 19:35:43.000000000 -0400 @@ -105,7 +105,8 @@ static void prefixify_subexp (struct exp int); static struct expression *parse_exp_in_context (char **, struct block *, int, - int); + int, + const struct language_defn *); void _initialize_parse (void); @@ -925,9 +926,10 @@ prefixify_subexp (struct expression *ine If COMMA is nonzero, stop if a comma is reached. */ struct expression * -parse_exp_1 (char **stringptr, struct block *block, int comma) +parse_exp_1 (char **stringptr, struct block *block, int comma, + const struct language_defn *language) { - return parse_exp_in_context (stringptr, block, comma, 0); + return parse_exp_in_context (stringptr, block, comma, 0, language); } /* As for parse_exp_1, except that if VOID_CONTEXT_P, then @@ -935,7 +937,8 @@ parse_exp_1 (char **stringptr, struct bl static struct expression * parse_exp_in_context (char **stringptr, struct block *block, int comma, - int void_context_p) + int void_context_p, + const struct language_defn *language) { struct cleanup *old_chain; @@ -979,11 +982,11 @@ parse_exp_in_context (char **stringptr, expout_ptr = 0; expout = (struct expression *) xmalloc (sizeof (struct expression) + EXP_ELEM_TO_BYTES (expout_size)); - expout->language_defn = current_language; + expout->language_defn = language; make_cleanup (free_current_contents, &expout); - if (current_language->la_parser ()) - current_language->la_error (NULL); + if (language->la_parser ()) + language->la_error (NULL); discard_cleanups (old_chain); @@ -1005,7 +1008,7 @@ parse_exp_in_context (char **stringptr, prefixify_expression (expout); - current_language->la_post_parser (&expout, void_context_p); + language->la_post_parser (&expout, void_context_p); if (expressiondebug) dump_prefix_expression (expout, gdb_stdlog); @@ -1018,10 +1021,10 @@ parse_exp_in_context (char **stringptr, to use up all of the contents of STRING. */ struct expression * -parse_expression (char *string) +parse_expression (char *string, const struct language_defn *language) { struct expression *exp; - exp = parse_exp_1 (&string, 0, 0); + exp = parse_exp_1 (&string, 0, 0, language); if (*string) error (_("Junk after end of expression.")); return exp; @@ -1032,10 +1035,11 @@ parse_expression (char *string) no value is expected from the expression. */ struct expression * -parse_expression_in_context (char *string, int void_context_p) +parse_expression_in_context (char *string, int void_context_p, + const struct language_defn *language) { struct expression *exp; - exp = parse_exp_in_context (&string, 0, 0, void_context_p); + exp = parse_exp_in_context (&string, 0, 0, void_context_p, language); if (*string != '\000') error (_("Junk after end of expression.")); return exp; diff -rup ../../gdb-public.0/gdb/printcmd.c ./printcmd.c --- ../../gdb-public.0/gdb/printcmd.c 2007-10-28 18:33:03.000000000 -0400 +++ ./printcmd.c 2007-10-28 19:35:43.000000000 -0400 @@ -864,7 +864,7 @@ print_command_1 (char *exp, int inspect, if (exp && *exp) { struct type *type; - expr = parse_expression (exp); + expr = parse_expression (exp, curr_language ()); old_chain = make_cleanup (free_current_contents, &expr); cleanup = 1; val = evaluate_expression (expr); @@ -949,7 +949,7 @@ output_command (char *exp, int from_tty) format = fmt.format; } - expr = parse_expression (exp); + expr = parse_expression (exp, current_language); old_chain = make_cleanup (free_current_contents, &expr); val = evaluate_expression (expr); @@ -969,7 +969,7 @@ output_command (char *exp, int from_tty) static void set_command (char *exp, int from_tty) { - struct expression *expr = parse_expression (exp); + struct expression *expr = parse_expression (exp, current_language); struct cleanup *old_chain = make_cleanup (free_current_contents, &expr); evaluate_expression (expr); @@ -1271,7 +1271,7 @@ x_command (char *exp, int from_tty) if (exp != 0 && *exp != 0) { - expr = parse_expression (exp); + expr = parse_expression (exp, current_language); /* Cause expression not to be there any more if this command is repeated with Newline. But don't clobber a user-defined command's definition. */ @@ -1366,7 +1366,7 @@ display_command (char *exp, int from_tty } innermost_block = 0; - expr = parse_expression (exp); + expr = parse_expression (exp, current_language); new = (struct display *) xmalloc (sizeof (struct display)); diff -rup ../../gdb-public.0/gdb/tracepoint.c ./tracepoint.c --- ../../gdb-public.0/gdb/tracepoint.c 2007-10-28 18:33:03.000000000 -0400 +++ ./tracepoint.c 2007-10-28 19:35:43.000000000 -0400 @@ -970,7 +970,8 @@ validate_actionline (char **line, struct } /* else fall thru, treat p as an expression and parse it! */ } - exp = parse_exp_1 (&p, block_for_pc (t->address), 1); + exp = parse_exp_1 (&p, block_for_pc (t->address), 1, + curr_language); old_chain = make_cleanup (free_current_contents, &exp); if (exp->elts[0].opcode == OP_VAR_VALUE) @@ -1598,7 +1599,8 @@ encode_actions (struct tracepoint *t, ch struct agent_reqs areqs; exp = parse_exp_1 (&action_exp, - block_for_pc (t->address), 1); + block_for_pc (t->address), 1, + curr_language ()); old_chain = make_cleanup (free_current_contents, &exp); switch (exp->elts[0].opcode) diff -rup ../../gdb-public.0/gdb/typeprint.c ./typeprint.c --- ../../gdb-public.0/gdb/typeprint.c 2007-10-28 18:33:03.000000000 -0400 +++ ./typeprint.c 2007-10-28 19:35:43.000000000 -0400 @@ -45,7 +45,7 @@ static void ptype_command (char *, int); static void whatis_command (char *, int); -static void whatis_exp (char *, int); +static void whatis_exp (char *, int, const struct language_defn *); /* Print a description of a type in the format of a typedef for the current language. @@ -109,7 +109,7 @@ type_print (struct type *type, char *var show is passed to type_print. */ static void -whatis_exp (char *exp, int show) +whatis_exp (char *exp, int show, const struct language_defn *language) { struct expression *expr; struct value *val; @@ -122,7 +122,7 @@ whatis_exp (char *exp, int show) if (exp) { - expr = parse_expression (exp); + expr = parse_expression (exp, language); old_chain = make_cleanup (free_current_contents, &expr); val = evaluate_type (expr); } @@ -175,7 +175,7 @@ whatis_command (char *exp, int from_tty) /* Most of the time users do not want to see all the fields in a structure. If they do they can use the "ptype" command. Hence the "-1" below. */ - whatis_exp (exp, -1); + whatis_exp (exp, -1, current_language); } /* TYPENAME is either the name of a type, or an expression. */ @@ -183,7 +183,7 @@ whatis_command (char *exp, int from_tty) static void ptype_command (char *typename, int from_tty) { - whatis_exp (typename, 1); + whatis_exp (typename, 1, current_language); } /* Print integral scalar data VAL, of type TYPE, onto stdio stream STREAM. @@ -283,7 +283,7 @@ maintenance_print_type (char *typename, if (typename != NULL) { - expr = parse_expression (typename); + expr = parse_expression (typename, current_language); old_chain = make_cleanup (free_current_contents, &expr); if (expr->elts[0].opcode == OP_TYPE) { diff -rup ../../gdb-public.0/gdb/value.c ./value.c --- ../../gdb-public.0/gdb/value.c 2007-10-28 18:33:03.000000000 -0400 +++ ./value.c 2007-10-28 19:35:43.000000000 -0400 @@ -714,7 +714,7 @@ init_if_undefined_command (char* args, i struct internalvar* intvar; /* Parse the expression - this is taken from set_command(). */ - struct expression *expr = parse_expression (args); + struct expression *expr = parse_expression (args, current_language); register struct cleanup *old_chain = make_cleanup (free_current_contents, &expr); diff -rup ../../gdb-public.0/gdb/varobj.c ./varobj.c --- ../../gdb-public.0/gdb/varobj.c 2007-10-28 18:33:03.000000000 -0400 +++ ./varobj.c 2007-10-28 19:35:43.000000000 -0400 @@ -893,7 +893,7 @@ varobj_set_value (struct varobj *var, ch int i; input_radix = 10; /* ALWAYS reset to decimal temporarily */ - exp = parse_exp_1 (&s, 0, 0); + exp = parse_exp_1 (&s, 0, 0, curr_language ()); if (!gdb_evaluate_expression (exp, &value)) { /* We cannot proceed without a valid expression. */ diff -rup ../../gdb-public.0/gdb/wrapper.c ./wrapper.c --- ../../gdb-public.0/gdb/wrapper.c 2007-10-28 18:33:03.000000000 -0400 +++ ./wrapper.c 2007-10-28 19:35:43.000000000 -0400 @@ -20,6 +20,7 @@ #include "exceptions.h" #include "wrapper.h" #include "ui-out.h" +#include "language.h" int gdb_parse_exp_1 (char **stringptr, struct block *block, int comma, @@ -29,7 +30,7 @@ gdb_parse_exp_1 (char **stringptr, struc TRY_CATCH (except, RETURN_MASK_ERROR) { - *expression = parse_exp_1 (stringptr, block, comma); + *expression = parse_exp_1 (stringptr, block, comma, curr_language ()); } if (except.reason < 0)