diff -r e3c43da3934b gdb/defs.h --- a/gdb/defs.h Tue Oct 07 11:21:29 2008 -0400 +++ b/gdb/defs.h Thu Oct 09 08:55:57 2008 -0400 @@ -194,6 +194,23 @@ enum language language_minimal, /* All other languages, minimal support only */ nr_languages }; + +/* Parsing an expression is dependent on a certain context such as + the language to use, or the input radix for numbers. This structure + contains that context information. */ + +struct parse_context + { + /* The language to use when parsing an expression. */ + const struct language_defn *language; + + /* The radix to use by default when parsing numbers. */ + int radix; + }; + +/* A function that builds a parse_context structure containing + the current language and the current input radix. */ +struct parse_context current_parse_context (void); enum precision_type { diff -r e3c43da3934b gdb/parse.c --- a/gdb/parse.c Tue Oct 07 11:21:29 2008 -0400 +++ b/gdb/parse.c Thu Oct 09 08:55:57 2008 -0400 @@ -131,6 +131,16 @@ struct funcall }; static struct funcall *funcall_chain; + +struct parse_context +current_parse_context (void) +{ + struct parse_context parse_context; + + parse_context.language = current_language; + parse_context.radix = input_radix; + return parse_context; +} /* Begin counting arguments for a function call, saving the data about any containing call. */ diff -r e3c43da3934b gdb/command.h --- a/gdb/command.h Tue Oct 07 11:21:29 2008 -0400 +++ b/gdb/command.h Thu Oct 09 08:55:57 2008 -0400 @@ -98,34 +98,30 @@ struct cmd_list_element; /* Forward-declarations of the entry-points of cli/cli-decode.c. */ -extern struct cmd_list_element *add_cmd (char *, enum command_class, - void (*fun) (char *, int), char *, - struct cmd_list_element **); +extern struct cmd_list_element * + add_cmd (char *, enum command_class, + void (*fun) (char *, int, struct parse_context), + char *, struct cmd_list_element **); extern struct cmd_list_element *add_alias_cmd (char *, char *, enum command_class, int, struct cmd_list_element **); -extern struct cmd_list_element *add_prefix_cmd (char *, enum command_class, - void (*fun) (char *, int), - char *, - struct cmd_list_element **, - char *, int, - struct cmd_list_element **); +extern struct cmd_list_element * + add_prefix_cmd (char *, enum command_class, + void (*fun) (char *, int, struct parse_context), + char *, struct cmd_list_element **, char *, int, + struct cmd_list_element **); -extern struct cmd_list_element *add_abbrev_prefix_cmd (char *, - enum command_class, - void (*fun) (char *, - int), - char *, - struct cmd_list_element - **, char *, int, - struct cmd_list_element - **); +extern struct cmd_list_element * + add_abbrev_prefix_cmd (char *, enum command_class, + void (*fun) (char *, int, struct parse_context), + char *, struct cmd_list_element **, char *, int, + struct cmd_list_element **); /* Set the commands corresponding callback. */ -typedef void cmd_cfunc_ftype (char *args, int from_tty); +typedef void cmd_cfunc_ftype (char *args, int from_tty, struct parse_context); extern void set_cmd_cfunc (struct cmd_list_element *cmd, cmd_cfunc_ftype *cfunc); @@ -140,7 +136,8 @@ extern void set_cmd_completer (struct cm /* HACK: cagney/2002-02-23: Code, mostly in tracepoints.c, grubs around in cmd objects to test the value of the commands sfunc(). */ extern int cmd_cfunc_eq (struct cmd_list_element *cmd, - void (*cfunc) (char *args, int from_tty)); + void (*cfunc) (char *args, int from_tty, + struct parse_context)); /* Each command object has a local context attached to it. . */ extern void set_cmd_context (struct cmd_list_element *cmd, void *context); @@ -178,14 +175,17 @@ extern int struct cmd_list_element **prefix_cmd, struct cmd_list_element **cmd); -extern struct cmd_list_element *add_com (char *, enum command_class, - void (*fun) (char *, int), char *); +extern struct cmd_list_element * + add_com (char *, enum command_class, + void (*fun) (char *, int, struct parse_context), + char *); extern struct cmd_list_element *add_com_alias (char *, char *, enum command_class, int); -extern struct cmd_list_element *add_info (char *, void (*fun) (char *, int), - char *); +extern struct cmd_list_element * + add_info (char *, void (*fun) (char *, int, struct parse_context), + char *); extern struct cmd_list_element *add_info_alias (char *, char *, int); diff -r e3c43da3934b gdb/cli/cli-decode.h --- a/gdb/cli/cli-decode.h Tue Oct 07 11:21:29 2008 -0400 +++ b/gdb/cli/cli-decode.h Thu Oct 09 08:55:57 2008 -0400 @@ -201,35 +201,32 @@ struct cmd_list_element /* API to the manipulation of command lists. */ -extern struct cmd_list_element *add_cmd (char *, enum command_class, - void (*fun) (char *, int), char *, - struct cmd_list_element **); +extern struct cmd_list_element * + add_cmd (char *, enum command_class, + void (*fun) (char *, int, struct parse_context), + char *, struct cmd_list_element **); extern struct cmd_list_element *add_alias_cmd (char *, char *, enum command_class, int, struct cmd_list_element **); -extern struct cmd_list_element *add_prefix_cmd (char *, enum command_class, - void (*fun) (char *, int), - char *, - struct cmd_list_element **, - char *, int, - struct cmd_list_element **); +extern struct cmd_list_element * + add_prefix_cmd (char *, enum command_class, + void (*fun) (char *, int, struct parse_context), + char *, struct cmd_list_element **, char *, int, + struct cmd_list_element **); -extern struct cmd_list_element *add_abbrev_prefix_cmd (char *, - enum command_class, - void (*fun) (char *, - int), - char *, - struct cmd_list_element - **, char *, int, - struct cmd_list_element - **); +extern struct cmd_list_element * + add_abbrev_prefix_cmd (char *, enum command_class, + void (*fun) (char *, int, struct parse_context), + char *, struct cmd_list_element **, char *, int, + struct cmd_list_element **); /* Set the commands corresponding callback. */ extern void set_cmd_cfunc (struct cmd_list_element *cmd, - void (*cfunc) (char *args, int from_tty)); + void (*cfunc) (char *args, int from_tty, + struct parse_context)); extern void set_cmd_sfunc (struct cmd_list_element *cmd, void (*sfunc) (char *args, int from_tty, @@ -241,7 +238,8 @@ extern void set_cmd_completer (struct cm /* HACK: cagney/2002-02-23: Code, mostly in tracepoints.c, grubs around in cmd objects to test the value of the commands sfunc(). */ extern int cmd_cfunc_eq (struct cmd_list_element *cmd, - void (*cfunc) (char *args, int from_tty)); + void (*cfunc) (char *args, int from_tty, + struct parse_context)); /* Access to the command's local context. */ extern void set_cmd_context (struct cmd_list_element *cmd, void *context); @@ -275,14 +273,17 @@ extern int struct cmd_list_element **prefix_cmd, struct cmd_list_element **cmd); -extern struct cmd_list_element *add_com (char *, enum command_class, - void (*fun) (char *, int), char *); +extern struct cmd_list_element * + add_com (char *, enum command_class, + void (*fun) (char *, int, struct parse_context), + char *); extern struct cmd_list_element *add_com_alias (char *, char *, enum command_class, int); -extern struct cmd_list_element *add_info (char *, void (*fun) (char *, int), - char *); +extern struct cmd_list_element * + add_info (char *, void (*fun) (char *, int, struct parse_context), + char *); extern struct cmd_list_element *add_info_alias (char *, char *, int); diff -r e3c43da3934b gdb/cli/cli-decode.c --- a/gdb/cli/cli-decode.c Tue Oct 07 11:21:29 2008 -0400 +++ b/gdb/cli/cli-decode.c Thu Oct 09 08:55:57 2008 -0400 @@ -57,7 +57,7 @@ static void static void do_cfunc (struct cmd_list_element *c, char *args, int from_tty) { - c->function.cfunc (args, from_tty); /* Ok. */ + c->function.cfunc (args, from_tty, current_parse_context ()); /* Ok. */ } void @@ -88,7 +88,7 @@ set_cmd_sfunc (struct cmd_list_element * int cmd_cfunc_eq (struct cmd_list_element *cmd, - void (*cfunc) (char *args, int from_tty)) + void (*cfunc) (char *args, int from_tty, struct parse_context)) { return cmd->func == do_cfunc && cmd->function.cfunc == cfunc; } @@ -149,7 +149,8 @@ set_cmd_completer (struct cmd_list_eleme of *LIST). */ struct cmd_list_element * -add_cmd (char *name, enum command_class class, void (*fun) (char *, int), +add_cmd (char *name, enum command_class class, + void (*fun) (char *, int, struct parse_context), char *doc, struct cmd_list_element **list) { struct cmd_list_element *c @@ -261,7 +262,8 @@ add_alias_cmd (char *name, char *oldname of the variable containing that list. */ struct cmd_list_element * -add_prefix_cmd (char *name, enum command_class class, void (*fun) (char *, int), +add_prefix_cmd (char *name, enum command_class class, + void (*fun) (char *, int, struct parse_context), char *doc, struct cmd_list_element **prefixlist, char *prefixname, int allow_unknown, struct cmd_list_element **list) @@ -277,7 +279,8 @@ add_prefix_cmd (char *name, enum command struct cmd_list_element * add_abbrev_prefix_cmd (char *name, enum command_class class, - void (*fun) (char *, int), char *doc, + void (*fun) (char *, int, struct parse_context), + char *doc, struct cmd_list_element **prefixlist, char *prefixname, int allow_unknown, struct cmd_list_element **list) { @@ -657,7 +660,8 @@ delete_cmd (char *name, struct cmd_list_ /* Add an element to the list of info subcommands. */ struct cmd_list_element * -add_info (char *name, void (*fun) (char *, int), char *doc) +add_info (char *name, void (*fun) (char *, int, struct parse_context), + char *doc) { return add_cmd (name, no_class, fun, doc, &infolist); } @@ -673,7 +677,8 @@ add_info_alias (char *name, char *oldnam /* Add an element to the list of commands. */ struct cmd_list_element * -add_com (char *name, enum command_class class, void (*fun) (char *, int), +add_com (char *name, enum command_class class, + void (*fun) (char *, int, struct parse_context), char *doc) { return add_cmd (name, class, fun, doc, &cmdlist); diff -r e3c43da3934b gdb/exceptions.h --- a/gdb/exceptions.h Tue Oct 07 11:21:29 2008 -0400 +++ b/gdb/exceptions.h Thu Oct 09 08:55:57 2008 -0400 @@ -233,7 +233,7 @@ extern int catch_errors (catch_errors_ft /* Template to catch_errors() that wraps calls to command functions. */ -typedef void (catch_command_errors_ftype) (char *, int); +typedef void (catch_command_errors_ftype) (char *, int, struct parse_context); extern int catch_command_errors (catch_command_errors_ftype *func, char *command, int from_tty, return_mask); #endif diff -r e3c43da3934b gdb/exceptions.c --- a/gdb/exceptions.c Tue Oct 07 11:21:29 2008 -0400 +++ b/gdb/exceptions.c Thu Oct 09 08:55:57 2008 -0400 @@ -528,7 +528,7 @@ catch_command_errors (catch_command_erro volatile struct gdb_exception e; TRY_CATCH (e, mask) { - command (arg, from_tty); + command (arg, from_tty, current_parse_context ()); } print_any_exception (gdb_stderr, NULL, e); if (e.reason < 0) diff -r e3c43da3934b gdb/language.c --- a/gdb/language.c Tue Oct 07 11:21:29 2008 -0400 +++ b/gdb/language.c Thu Oct 09 08:55:57 2008 -0400 @@ -59,9 +59,9 @@ static void unk_lang_error (char *); static int unk_lang_parser (void); -static void show_check (char *, int); +static void show_check (char *, int, struct parse_context parse_context); -static void set_check (char *, int); +static void set_check (char *, int, struct parse_context parse_context); static void set_type_range_case (void); @@ -917,7 +917,7 @@ language_str (enum language lang) } static void -set_check (char *ignore, int from_tty) +set_check (char *ignore, int from_tty, struct parse_context parse_context) { printf_unfiltered ( "\"set check\" must be followed by the name of a check subcommand.\n"); @@ -925,7 +925,7 @@ set_check (char *ignore, int from_tty) } static void -show_check (char *ignore, int from_tty) +show_check (char *ignore, int from_tty, struct parse_context parse_context) { cmd_show_list (showchecklist, from_tty, ""); }