* [RFC] Reducing the use of current_language - some patches
@ 2007-10-31 10:47 Joel Brobecker
2007-11-04 17:15 ` Ulrich Weigand
0 siblings, 1 reply; 6+ messages in thread
From: Joel Brobecker @ 2007-10-31 10:47 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 3726 bytes --]
Hello,
As I said before, the goal of this exercise is to avoid having to play
with the current language in order to do parsing operations in a language
that may not be the current language.
The approach I'm taking to this is that functions that require a
language-specific operation to be done should either:
- know which language should be used (for instance, an Ada
exception catchpoint location should be parsed using the Ada
language)
- Or: Be passed the language to use as a parameter. This is by
far the most common case.
At the end of the exercise, the only functions that shoudl be using
the current_language are the function that implement GDB commands.
I've started working on this, and although it's far from being done,
the changes are touching a lot of files. I'm doing the transition
piece-meal, by starting from the expression-parsing routines, and
will work my way up until current_language is only used in "command"
functions.
More precisely, the algorithm used is:
- Modify the profile of some routines to add a language as a param.
- Modify the body of these routines to use that language instead
of the current_language
- Update the callers of this routine as follow:
1. If the caller implements a GDB command, then we know that
the user means that we should be using the current language
to evaluate his command.
If the function is only called by "command" functions, then
I may elect to use "current_language". Adding an extra
language parameter to that function would be cleaner, but
on the other hand wouldn't change anything. Not adding it
reduces the size of the patch.
2. Otherwise, If we have the language handy, then use that language
(eg: if the language is a parameter, or if we're given
a breakpoint as a parameter, for instance)
3. If the language is not handily available *yet*, then
use a temporary function called "curr_language ()" that
returns the current_language.
In essence, this is like updating the call to use current_language
except that I'm marking this specific instance so that I can
easily find again later which uses of current_language I have
introduced but still need to be removed.
Note that, when I post the final patches for review,
curr_language will be removed, and replaced with plain
old current_language. This is only used by me as a helper.
At each iteration, I look for some instances of "curr_language",
choose a routine that I want to adjust, and then apply the algorithm
above.
I'm done when there are no longer any curr_language calls :).
Although the changes are rather mechanical, they are fairly extensive
and touch a lot of files. I would really apprieciate some feedback
on the patches attached to this email. This is only a preview of the
entire work which I hope to complete soon.
The patches do:
- 01-parse_expr.diff:
Update the parse_expression routines, update the callers.
- 02-breakpoint.c.diff:
Transition breakpoint.c. Update all the callers of the functions
that were adjusted.
- 03-parse_and_eval_address.diff:
Update parse_and_eval_address. Update all callers.
I have a bunch of other functions in eval.c that I can transition
as separate patches, so the patches should be reasonably small.
I might bunch them together and that would make one large patch
instead of a collection of small ones, but that would be slightly
simpler for me, because it reduces the number of patches (which may
be large by the time I'm done).
So? Does this look OK for everyone?
Thanks,
--
Joel
[-- Attachment #2: 01-parse_expr.diff --]
[-- Type: text/plain, Size: 22122 bytes --]
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 <ctype.h>
#include <sys/time.h>
@@ -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)
[-- Attachment #3: 02-breakpoint.c.diff --]
[-- Type: text/plain, Size: 16393 bytes --]
diff -rup ../../gdb-public.1/gdb/Makefile.in ./Makefile.in
--- ../../gdb-public.1/gdb/Makefile.in 2007-10-28 19:35:43.000000000 -0400
+++ ./Makefile.in 2007-10-30 22:00:50.000000000 -0400
@@ -3114,7 +3114,7 @@ gdbtk-wrapper.o: $(srcdir)/gdbtk/generic
mi-cmd-break.o: $(srcdir)/mi/mi-cmd-break.c $(defs_h) $(mi_cmds_h) \
$(ui_out_h) $(mi_out_h) $(breakpoint_h) $(gdb_string_h) \
- $(mi_getopt_h) $(gdb_events_h) $(gdb_h)
+ $(mi_getopt_h) $(gdb_events_h) $(gdb_h) $(language_h)
$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-break.c
mi-cmd-disas.o: $(srcdir)/mi/mi-cmd-disas.c $(defs_h) $(target_h) $(value_h) \
$(mi_cmds_h) $(mi_getopt_h) $(gdb_string_h) $(ui_out_h) $(disasm_h)
diff -rup ../../gdb-public.1/gdb/breakpoint.c ./breakpoint.c
--- ../../gdb-public.1/gdb/breakpoint.c 2007-10-28 19:40:08.000000000 -0400
+++ ./breakpoint.c 2007-10-30 22:00:50.000000000 -0400
@@ -90,11 +90,13 @@ static void watch_command (char *, int);
static int can_use_hardware_watchpoint (struct value *);
-static int break_command_1 (char *, int, int, struct breakpoint *);
+static int break_command_1 (char *, int, int, struct breakpoint *,
+ const struct language_defn *);
static void mention (struct breakpoint *);
-struct breakpoint *set_raw_breakpoint (struct symtab_and_line, enum bptype);
+struct breakpoint *set_raw_breakpoint (struct symtab_and_line, enum bptype,
+ const struct language_defn *);
static void check_duplicates (struct breakpoint *);
@@ -161,7 +163,7 @@ static void hbreak_command (char *, int)
static void thbreak_command (char *, int);
-static void watch_command_1 (char *, int, int);
+static void watch_command_1 (char *, int, int, const struct language_defn *);
static void rwatch_command (char *, int);
@@ -4326,7 +4328,8 @@ static void free_bp_location (struct bp_
that has type BPTYPE and has no locations as yet. */
struct breakpoint *
-set_raw_breakpoint_without_location (enum bptype bptype)
+set_raw_breakpoint_without_location (enum bptype bptype,
+ const struct language_defn *language)
{
struct breakpoint *b, *b1;
@@ -4334,7 +4337,7 @@ set_raw_breakpoint_without_location (enu
memset (b, 0, sizeof (*b));
b->type = bptype;
- b->language = current_language->la_language;
+ b->language = language->la_language;
b->input_radix = input_radix;
b->thread = -1;
b->enable_state = bp_enabled;
@@ -4396,9 +4399,11 @@ set_breakpoint_location_function (struct
should happen, a bogus breakpoint will be left on the chain. */
struct breakpoint *
-set_raw_breakpoint (struct symtab_and_line sal, enum bptype bptype)
+set_raw_breakpoint (struct symtab_and_line sal, enum bptype bptype,
+ const struct language_defn *language)
{
- struct breakpoint *b = set_raw_breakpoint_without_location (bptype);
+ struct breakpoint *b =
+ set_raw_breakpoint_without_location (bptype, language);
CORE_ADDR adjusted_address;
/* Adjust the breakpoint's address prior to allocating a location.
@@ -4459,7 +4464,7 @@ create_internal_breakpoint (CORE_ADDR ad
sal.pc = address;
sal.section = find_pc_overlay (sal.pc);
- b = set_raw_breakpoint (sal, type);
+ b = set_raw_breakpoint (sal, type, language_def (language_c));
b->number = internal_breakpoint_number--;
b->disposition = disp_donttouch;
@@ -4751,7 +4756,7 @@ solib_load_unload_1 (char *hookname, int
if (canonical != (char **) NULL)
discard_cleanups (canonical_strings_chain);
- b = set_raw_breakpoint (sals.sals[0], bp_kind);
+ b = set_raw_breakpoint (sals.sals[0], bp_kind, language_def (language_c));
set_breakpoint_count (breakpoint_count + 1);
b->number = breakpoint_count;
b->cond_string = (cond_string == NULL) ?
@@ -4807,7 +4812,7 @@ create_fork_vfork_event_catchpoint (int
sal.symtab = NULL;
sal.line = 0;
- b = set_raw_breakpoint (sal, bp_kind);
+ b = set_raw_breakpoint (sal, bp_kind, language_def (language_c));
set_breakpoint_count (breakpoint_count + 1);
b->number = breakpoint_count;
b->cond_string = (cond_string == NULL) ?
@@ -4845,7 +4850,7 @@ create_exec_event_catchpoint (int tempfl
sal.symtab = NULL;
sal.line = 0;
- b = set_raw_breakpoint (sal, bp_catch_exec);
+ b = set_raw_breakpoint (sal, bp_catch_exec, language_def (language_c));
set_breakpoint_count (breakpoint_count + 1);
b->number = breakpoint_count;
b->cond_string = (cond_string == NULL) ?
@@ -4969,7 +4974,7 @@ set_momentary_breakpoint (struct symtab_
enum bptype type)
{
struct breakpoint *b;
- b = set_raw_breakpoint (sal, type);
+ b = set_raw_breakpoint (sal, type, current_language);
b->enable_state = bp_enabled;
b->disposition = disp_donttouch;
b->frame_id = frame_id;
@@ -5173,7 +5178,8 @@ create_breakpoint (struct symtabs_and_li
char *cond_string,
enum bptype type, enum bpdisp disposition,
int thread, int ignore_count, int from_tty,
- struct breakpoint *pending_bp)
+ struct breakpoint *pending_bp,
+ const struct language_defn *language)
{
struct breakpoint *b = NULL;
int i;
@@ -5200,7 +5206,7 @@ create_breakpoint (struct symtabs_and_li
if (i == 0)
{
- b = set_raw_breakpoint (sal, type);
+ b = set_raw_breakpoint (sal, type, language);
set_breakpoint_count (breakpoint_count + 1);
b->number = breakpoint_count;
b->thread = thread;
@@ -5389,7 +5395,8 @@ create_breakpoints (struct symtabs_and_l
char *cond_string,
enum bptype type, enum bpdisp disposition,
int thread, int ignore_count, int from_tty,
- struct breakpoint *pending_bp)
+ struct breakpoint *pending_bp,
+ const struct language_defn *language)
{
int i;
for (i = 0; i < sals.nelts; ++i)
@@ -5400,7 +5407,7 @@ create_breakpoints (struct symtabs_and_l
create_breakpoint (expanded, addr_string[i],
cond_string, type, disposition,
thread, ignore_count, from_tty,
- pending_bp);
+ pending_bp, language);
}
}
@@ -5505,7 +5512,8 @@ do_captured_parse_breakpoint (struct ui_
If no thread is found, *THREAD is set to -1. */
static void
find_condition_and_thread (char *tok, CORE_ADDR pc,
- char **cond_string, int *thread)
+ char **cond_string, int *thread,
+ const struct language_defn *language)
{
*cond_string = NULL;
*thread = -1;
@@ -5528,7 +5536,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, curr_language ());
+ parse_exp_1 (&tok, block_for_pc (pc), 0, language);
cond_end = tok;
*cond_string = savestring (cond_start,
cond_end - cond_start);
@@ -5558,7 +5566,9 @@ find_condition_and_thread (char *tok, CO
a pending breakpoint. */
static int
-break_command_1 (char *arg, int flag, int from_tty, struct breakpoint *pending_bp)
+break_command_1 (char *arg, int flag, int from_tty,
+ struct breakpoint *pending_bp,
+ const struct language_defn *language)
{
struct gdb_exception e;
int tempflag, hardwareflag;
@@ -5683,7 +5693,8 @@ break_command_1 (char *arg, int flag, in
from thread number, so parsing in context of first
sal is OK. When setting the breakpoint we'll
re-parse it in context of each sal. */
- find_condition_and_thread (arg, sals.sals[0].pc, &cond_string, &thread);
+ find_condition_and_thread (arg, sals.sals[0].pc, &cond_string, &thread,
+ language);
if (cond_string)
make_cleanup (xfree, cond_string);
create_breakpoints (sals, addr_string, cond_string,
@@ -5691,7 +5702,7 @@ break_command_1 (char *arg, int flag, in
: bp_breakpoint,
tempflag ? disp_del : disp_donttouch,
thread, ignore_count, from_tty,
- pending_bp);
+ pending_bp, language);
}
else
{
@@ -5702,7 +5713,7 @@ break_command_1 (char *arg, int flag, in
b = set_raw_breakpoint_without_location (hardwareflag
? bp_hardware_breakpoint
- : bp_breakpoint);
+ : bp_breakpoint, language);
set_breakpoint_count (breakpoint_count + 1);
b->number = breakpoint_count;
b->thread = thread;
@@ -5739,6 +5750,7 @@ struct captured_breakpoint_args
int tempflag;
int thread;
int ignore_count;
+ const struct language_defn *language;
};
static int
@@ -5814,7 +5826,7 @@ do_captured_breakpoint (struct ui_out *u
args->hardwareflag ? bp_hardware_breakpoint : bp_breakpoint,
args->tempflag ? disp_del : disp_donttouch,
args->thread, args->ignore_count, 0/*from-tty*/,
- NULL/*pending_bp*/);
+ NULL/*pending_bp*/, args->language);
/* That's it. Discard the cleanups for data inserted into the
breakpoint. */
@@ -5828,7 +5840,8 @@ enum gdb_rc
gdb_breakpoint (char *address, char *condition,
int hardwareflag, int tempflag,
int thread, int ignore_count,
- char **error_message)
+ char **error_message,
+ const struct language_defn *language)
{
struct captured_breakpoint_args args;
args.address = address;
@@ -5837,6 +5850,7 @@ gdb_breakpoint (char *address, char *con
args.tempflag = tempflag;
args.thread = thread;
args.ignore_count = ignore_count;
+ args.language = language;
if (catch_exceptions_with_msg (uiout, do_captured_breakpoint, &args,
error_message, RETURN_MASK_ALL) < 0)
return GDB_RC_FAIL;
@@ -5897,25 +5911,26 @@ resolve_sal_pc (struct symtab_and_line *
void
break_command (char *arg, int from_tty)
{
- break_command_1 (arg, 0, from_tty, NULL);
+ break_command_1 (arg, 0, from_tty, NULL, current_language);
}
void
tbreak_command (char *arg, int from_tty)
{
- break_command_1 (arg, BP_TEMPFLAG, from_tty, NULL);
+ break_command_1 (arg, BP_TEMPFLAG, from_tty, NULL, current_language);
}
static void
hbreak_command (char *arg, int from_tty)
{
- break_command_1 (arg, BP_HARDWAREFLAG, from_tty, NULL);
+ break_command_1 (arg, BP_HARDWAREFLAG, from_tty, NULL, current_language);
}
static void
thbreak_command (char *arg, int from_tty)
{
- break_command_1 (arg, (BP_TEMPFLAG | BP_HARDWAREFLAG), from_tty, NULL);
+ break_command_1 (arg, (BP_TEMPFLAG | BP_HARDWAREFLAG), from_tty, NULL,
+ current_language);
}
static void
@@ -5956,7 +5971,7 @@ stopin_command (char *arg, int from_tty)
if (badInput)
printf_filtered (_("Usage: stop in <function | address>\n"));
else
- break_command_1 (arg, 0, from_tty, NULL);
+ break_command_1 (arg, 0, from_tty, NULL, current_language);
}
static void
@@ -5988,14 +6003,15 @@ stopat_command (char *arg, int from_tty)
if (badInput)
printf_filtered (_("Usage: stop at <line>\n"));
else
- break_command_1 (arg, 0, from_tty, NULL);
+ break_command_1 (arg, 0, from_tty, NULL, current_language);
}
/* accessflag: hw_write: watch write,
hw_read: watch read,
hw_access: watch access (read or write) */
static void
-watch_command_1 (char *arg, int accessflag, int from_tty)
+watch_command_1 (char *arg, int accessflag, int from_tty,
+ const struct language_defn *language)
{
struct breakpoint *b, *scope_breakpoint = NULL;
struct symtab_and_line sal;
@@ -6020,7 +6036,7 @@ watch_command_1 (char *arg, int accessfl
/* Parse arguments. */
innermost_block = NULL;
exp_start = arg;
- exp = parse_exp_1 (&arg, 0, 0, curr_language ());
+ exp = parse_exp_1 (&arg, 0, 0, language);
exp_end = arg;
exp_valid_block = innermost_block;
mark = value_mark ();
@@ -6041,7 +6057,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, curr_language ());
+ cond = parse_exp_1 (&tok, 0, 0, language);
cond_end = tok;
}
if (*tok)
@@ -6107,7 +6123,7 @@ watch_command_1 (char *arg, int accessfl
}
/* Now set up the breakpoint. */
- b = set_raw_breakpoint (sal, bp_type);
+ b = set_raw_breakpoint (sal, bp_type, language);
set_breakpoint_count (breakpoint_count + 1);
b->number = breakpoint_count;
b->disposition = disp_donttouch;
@@ -6224,7 +6240,7 @@ watch_command_wrapper (char *arg, int fr
static void
watch_command (char *arg, int from_tty)
{
- watch_command_1 (arg, hw_write, from_tty);
+ watch_command_1 (arg, hw_write, from_tty, current_language);
}
void
@@ -6236,7 +6252,7 @@ rwatch_command_wrapper (char *arg, int f
static void
rwatch_command (char *arg, int from_tty)
{
- watch_command_1 (arg, hw_read, from_tty);
+ watch_command_1 (arg, hw_read, from_tty, current_language);
}
void
@@ -6248,7 +6264,7 @@ awatch_command_wrapper (char *arg, int f
static void
awatch_command (char *arg, int from_tty)
{
- watch_command_1 (arg, hw_access, from_tty);
+ watch_command_1 (arg, hw_access, from_tty, current_language);
}
\f
@@ -6643,7 +6659,7 @@ create_exception_catchpoint (int tempfla
error (_("Internal error -- invalid catchpoint kind"));
}
- b = set_raw_breakpoint (*sal, bptype);
+ b = set_raw_breakpoint (*sal, bptype, language_def (language_cplus));
set_breakpoint_count (breakpoint_count + 1);
b->number = breakpoint_count;
b->cond_string = (cond_string == NULL) ?
@@ -6722,7 +6738,8 @@ handle_gnu_v3_exceptions (int tempflag,
return 0;
}
- b = set_raw_breakpoint (sals.sals[0], bp_breakpoint);
+ b = set_raw_breakpoint (sals.sals[0], bp_breakpoint,
+ language_def (language_cplus));
set_breakpoint_count (breakpoint_count + 1);
b->number = breakpoint_count;
b->cond_string = (cond_string == NULL) ?
@@ -6804,7 +6821,7 @@ create_ada_exception_breakpoint (struct
enough for now, though. */
}
- b = set_raw_breakpoint (sal, bp_breakpoint);
+ b = set_raw_breakpoint (sal, bp_breakpoint, language_def (language_ada));
set_breakpoint_count (breakpoint_count + 1);
b->enable_state = bp_enabled;
@@ -6990,7 +7007,7 @@ struct breakpoint *
set_breakpoint_sal (struct symtab_and_line sal)
{
struct breakpoint *b;
- b = set_raw_breakpoint (sal, bp_breakpoint);
+ b = set_raw_breakpoint (sal, bp_breakpoint, curr_language ());
set_breakpoint_count (breakpoint_count + 1);
b->number = breakpoint_count;
b->thread = -1;
@@ -7668,7 +7685,8 @@ breakpoint_re_set_one (void *bint)
char *cond_string = 0;
int thread = -1;
find_condition_and_thread (s, sals.sals[0].pc,
- &cond_string, &thread);
+ &cond_string, &thread,
+ language_def (b->language));
if (cond_string)
b->cond_string = cond_string;
b->thread = thread;
diff -rup ../../gdb-public.1/gdb/gdb.h ./gdb.h
--- ../../gdb-public.1/gdb/gdb.h 2007-10-28 19:35:43.000000000 -0400
+++ ./gdb.h 2007-10-30 22:00:51.000000000 -0400
@@ -20,6 +20,7 @@
#define GDB_H
struct ui_out;
+struct language_defn;
/* Return-code (RC) from a gdb library call. (The abreviation RC is
taken from the sim/common directory.) */
@@ -51,7 +52,8 @@ enum gdb_rc gdb_breakpoint_query (struct
enum gdb_rc gdb_breakpoint (char *address, char *condition,
int hardwareflag, int tempflag,
int thread, int ignore_count,
- char **error_message);
+ char **error_message,
+ const struct language_defn *language);
/* Switch thread and print notification. */
enum gdb_rc gdb_thread_select (struct ui_out *uiout, char *tidstr,
diff -rup ../../gdb-public.1/gdb/mi/mi-cmd-break.c ./mi/mi-cmd-break.c
--- ../../gdb-public.1/gdb/mi/mi-cmd-break.c 2007-10-28 19:35:43.000000000 -0400
+++ ./mi/mi-cmd-break.c 2007-10-30 22:00:52.000000000 -0400
@@ -26,6 +26,7 @@
#include "mi-getopt.h"
#include "gdb-events.h"
#include "gdb.h"
+#include "language.h"
enum
{
@@ -139,13 +140,13 @@ mi_cmd_break_insert (char *command, char
rc = gdb_breakpoint (address, condition,
0 /*hardwareflag */ , temp_p,
thread, ignore_count,
- &mi_error_message);
+ &mi_error_message, current_language);
break;
case HW_BP:
rc = gdb_breakpoint (address, condition,
1 /*hardwareflag */ , temp_p,
thread, ignore_count,
- &mi_error_message);
+ &mi_error_message, current_language);
break;
#if 0
case REGEXP_BP:
[-- Attachment #4: 03-parse_and_eval_address.diff --]
[-- Type: text/plain, Size: 16919 bytes --]
diff -rup ../../gdb-public.2/gdb/Makefile.in ./Makefile.in
--- ../../gdb-public.2/gdb/Makefile.in 2007-10-30 22:00:50.000000000 -0400
+++ ./Makefile.in 2007-10-30 22:23:37.000000000 -0400
@@ -2129,7 +2129,7 @@ hppa-tdep.o: hppa-tdep.c $(defs_h) $(bfd
$(completer_h) $(osabi_h) $(gdb_assert_h) $(gdb_stdint_h) \
$(arch_utils_h) $(symtab_h) $(dis_asm_h) $(trad_frame_h) \
$(frame_unwind_h) $(frame_base_h) $(gdbcore_h) $(gdbcmd_h) \
- $(objfiles_h) $(hppa_tdep_h) $(gdbtypes_h)
+ $(objfiles_h) $(hppa_tdep_h) $(gdbtypes_h) $(language_h)
hpux-thread.o: hpux-thread.c $(defs_h) $(gdbthread_h) $(target_h) \
$(inferior_h) $(regcache_h) $(gdb_stat_h) $(gdbcore_h) \
$(hppa_tdep_h) $(observer_h)
@@ -2783,7 +2783,8 @@ symfile.o: symfile.c $(defs_h) $(bfdlink
$(parser_defs_h) $(varobj_h) $(elf_bfd_h)
symfile-mem.o: symfile-mem.c $(defs_h) $(symtab_h) $(gdbcore_h) \
$(objfiles_h) $(exceptions_h) $(gdbcmd_h) $(target_h) $(value_h) \
- $(symfile_h) $(observer_h) $(auxv_h) $(elf_common_h)
+ $(symfile_h) $(observer_h) $(auxv_h) $(elf_common_h) \
+ $(language_h)
symmisc.o: symmisc.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(bfd_h) \
$(symfile_h) $(objfiles_h) $(breakpoint_h) $(command_h) \
$(gdb_obstack_h) $(exceptions_h) $(language_h) $(bcache_h) \
@@ -2935,7 +2936,8 @@ cli-decode.o: $(srcdir)/cli/cli-decode.c
$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/cli/cli-decode.c
cli-dump.o: $(srcdir)/cli/cli-dump.c $(defs_h) $(gdb_string_h) \
$(cli_decode_h) $(cli_cmds_h) $(value_h) $(completer_h) \
- $(cli_dump_h) $(gdb_assert_h) $(target_h) $(readline_h)
+ $(cli_dump_h) $(gdb_assert_h) $(target_h) $(readline_h) \
+ $(language_h)
$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/cli/cli-dump.c
cli-interp.o: $(srcdir)/cli/cli-interp.c $(defs_h) $(interps_h) $(wrapper_h) \
$(event_top_h) $(ui_out_h) $(cli_out_h) $(top_h) $(gdb_string_h) \
@@ -3117,7 +3119,8 @@ mi-cmd-break.o: $(srcdir)/mi/mi-cmd-brea
$(mi_getopt_h) $(gdb_events_h) $(gdb_h) $(language_h)
$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-break.c
mi-cmd-disas.o: $(srcdir)/mi/mi-cmd-disas.c $(defs_h) $(target_h) $(value_h) \
- $(mi_cmds_h) $(mi_getopt_h) $(gdb_string_h) $(ui_out_h) $(disasm_h)
+ $(mi_cmds_h) $(mi_getopt_h) $(gdb_string_h) $(ui_out_h) $(disasm_h) \
+ $(language_h)
$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-disas.c
mi-cmd-env.o: $(srcdir)/mi/mi-cmd-env.c $(defs_h) $(inferior_h) $(value_h) \
$(mi_out_h) $(mi_cmds_h) $(mi_getopt_h) $(symtab_h) $(target_h) \
diff -rup ../../gdb-public.2/gdb/ada-lang.c ./ada-lang.c
--- ../../gdb-public.2/gdb/ada-lang.c 2007-10-30 22:00:50.000000000 -0400
+++ ./ada-lang.c 2007-10-30 22:23:37.000000000 -0400
@@ -9214,7 +9214,7 @@ ada_find_printable_frame (struct frame_i
static CORE_ADDR
ada_unhandled_exception_name_addr (void)
{
- return parse_and_eval_address ("e.full_name");
+ return parse_and_eval_address ("e.full_name", language_def (language_ada));
}
/* Same as ada_unhandled_exception_name_addr, except that this function
@@ -9251,7 +9251,7 @@ ada_unhandled_exception_name_addr_from_r
return 0;
select_frame (fi);
- return parse_and_eval_address ("id.full_name");
+ return parse_and_eval_address ("id.full_name", language_def (language_ada));
}
/* Assuming the inferior just triggered an Ada exception catchpoint
@@ -9267,7 +9267,8 @@ ada_exception_name_addr_1 (enum exceptio
switch (ex)
{
case ex_catch_exception:
- return (parse_and_eval_address ("e.full_name"));
+ return (parse_and_eval_address ("e.full_name",
+ language_def (language_ada)));
break;
case ex_catch_exception_unhandled:
diff -rup ../../gdb-public.2/gdb/bsd-kvm.c ./bsd-kvm.c
--- ../../gdb-public.2/gdb/bsd-kvm.c 2007-10-30 22:00:50.000000000 -0400
+++ ./bsd-kvm.c 2007-10-30 22:23:37.000000000 -0400
@@ -261,7 +261,7 @@ bsd_kvm_proc_cmd (char *arg, int fromtty
if (core_kd == NULL)
error (_("No kernel memory image."));
- addr = parse_and_eval_address (arg);
+ addr = parse_and_eval_address (arg, current_language);
#ifdef HAVE_STRUCT_LWP
addr += offsetof (struct lwp, l_addr);
#else
@@ -289,7 +289,8 @@ bsd_kvm_pcb_cmd (char *arg, int fromtty)
if (core_kd == NULL)
error (_("No kernel memory image."));
- bsd_kvm_paddr = (struct pcb *)(u_long) parse_and_eval_address (arg);
+ bsd_kvm_paddr = (struct pcb *)(u_long)
+ parse_and_eval_address (arg, current_language);
target_fetch_registers (get_current_regcache (), -1);
diff -rup ../../gdb-public.2/gdb/cli/cli-cmds.c ./cli/cli-cmds.c
--- ../../gdb-public.2/gdb/cli/cli-cmds.c 2007-10-30 22:00:51.000000000 -0400
+++ ./cli/cli-cmds.c 2007-10-30 22:23:37.000000000 -0400
@@ -928,7 +928,7 @@ disassemble_command (char *arg, int from
else if (!(space_index = (char *) strchr (arg, ' ')))
{
/* One argument. */
- pc = parse_and_eval_address (arg);
+ pc = parse_and_eval_address (arg, current_language);
if (find_pc_partial_function (pc, &name, &low, &high) == 0)
error (_("No function contains specified address."));
#if defined(TUI)
@@ -944,8 +944,8 @@ disassemble_command (char *arg, int from
{
/* Two arguments. */
*space_index = '\0';
- low = parse_and_eval_address (arg);
- high = parse_and_eval_address (space_index + 1);
+ low = parse_and_eval_address (arg, current_language);
+ high = parse_and_eval_address (space_index + 1, current_language);
}
#if defined(TUI)
diff -rup ../../gdb-public.2/gdb/cli/cli-dump.c ./cli/cli-dump.c
--- ../../gdb-public.2/gdb/cli/cli-dump.c 2007-10-30 22:00:51.000000000 -0400
+++ ./cli/cli-dump.c 2007-10-30 22:23:37.000000000 -0400
@@ -30,6 +30,7 @@
#include <ctype.h>
#include "target.h"
#include "readline/readline.h"
+#include "language.h"
#define XMALLOC(TYPE) ((TYPE*) xmalloc (sizeof (TYPE)))
@@ -249,8 +250,8 @@ dump_memory_to_file (char *cmd, char *mo
error (_("Missing stop address."));
hi_exp = cmd;
- lo = parse_and_eval_address (lo_exp);
- hi = parse_and_eval_address (hi_exp);
+ lo = parse_and_eval_address (lo_exp, current_language);
+ hi = parse_and_eval_address (hi_exp, current_language);
if (hi <= lo)
error (_("Invalid memory address range (start >= end)."));
count = hi - lo;
diff -rup ../../gdb-public.2/gdb/eval.c ./eval.c
--- ../../gdb-public.2/gdb/eval.c 2007-10-30 22:00:51.000000000 -0400
+++ ./eval.c 2007-10-30 22:23:37.000000000 -0400
@@ -80,9 +80,9 @@ evaluate_subexp (struct type *expect_typ
and return the result as a number. */
CORE_ADDR
-parse_and_eval_address (char *exp)
+parse_and_eval_address (char *exp, const struct language_defn *language)
{
- struct expression *expr = parse_expression (exp, curr_language ());
+ struct expression *expr = parse_expression (exp, language);
CORE_ADDR addr;
struct cleanup *old_chain =
make_cleanup (free_current_contents, &expr);
diff -rup ../../gdb-public.2/gdb/exec.c ./exec.c
--- ../../gdb-public.2/gdb/exec.c 2007-10-30 22:00:51.000000000 -0400
+++ ./exec.c 2007-10-30 22:23:37.000000000 -0400
@@ -647,7 +647,7 @@ set_section_command (char *args, int fro
seclen = args - secname;
/* Parse out new virtual address */
- secaddr = parse_and_eval_address (args);
+ secaddr = parse_and_eval_address (args, current_language);
for (p = exec_ops.to_sections; p < exec_ops.to_sections_end; p++)
{
diff -rup ../../gdb-public.2/gdb/gnu-nat.c ./gnu-nat.c
--- ../../gdb-public.2/gdb/gnu-nat.c 2007-10-30 22:00:51.000000000 -0400
+++ ./gnu-nat.c 2007-10-30 22:23:37.000000000 -0400
@@ -2856,7 +2856,7 @@ set_task_exc_port_cmd (char *args, int f
struct inf *inf = cur_inf ();
if (!args)
error (_("No argument to \"set task exception-port\" command."));
- steal_exc_port (inf->task, parse_and_eval_address (args));
+ steal_exc_port (inf->task, parse_and_eval_address (args, current_language));
}
static void
@@ -3261,7 +3261,7 @@ set_thread_exc_port_cmd (char *args, int
struct proc *thread = cur_thread ();
if (!args)
error (_("No argument to \"set thread exception-port\" command."));
- steal_exc_port (thread, parse_and_eval_address (args));
+ steal_exc_port (thread, parse_and_eval_address (args, current_language));
}
#if 0
diff -rup ../../gdb-public.2/gdb/go32-nat.c ./go32-nat.c
--- ../../gdb-public.2/gdb/go32-nat.c 2007-10-30 22:00:51.000000000 -0400
+++ ./go32-nat.c 2007-10-30 22:23:37.000000000 -0400
@@ -1874,7 +1874,7 @@ go32_pte_for_address (char *arg, int fro
arg++;
if (*arg)
- addr = parse_and_eval_address (arg);
+ addr = parse_and_eval_address (arg, current_language);
}
if (!addr)
error_no_arg (_("linear address"));
diff -rup ../../gdb-public.2/gdb/hppa-tdep.c ./hppa-tdep.c
--- ../../gdb-public.2/gdb/hppa-tdep.c 2007-10-30 22:00:51.000000000 -0400
+++ ./hppa-tdep.c 2007-10-30 22:23:37.000000000 -0400
@@ -43,6 +43,7 @@
#include "gdbtypes.h"
#include "objfiles.h"
#include "hppa-tdep.h"
+#include "language.h"
static int hppa_debug = 0;
@@ -2524,7 +2525,7 @@ unwind_command (char *exp, int from_tty)
/* If we have an expression, evaluate it and use it as the address. */
if (exp != 0 && *exp != 0)
- address = parse_and_eval_address (exp);
+ address = parse_and_eval_address (exp, current_language);
else
return;
diff -rup ../../gdb-public.2/gdb/maint.c ./maint.c
--- ../../gdb-public.2/gdb/maint.c 2007-10-30 22:00:51.000000000 -0400
+++ ./maint.c 2007-10-30 22:23:37.000000000 -0400
@@ -474,7 +474,7 @@ maintenance_translate_address (char *arg
error (_("Unknown section %s."), arg);
}
- address = parse_and_eval_address (p);
+ address = parse_and_eval_address (p, current_language);
if (sect)
sym = lookup_minimal_symbol_by_pc_section (address, sect);
diff -rup ../../gdb-public.2/gdb/memattr.c ./memattr.c
--- ../../gdb-public.2/gdb/memattr.c 2007-10-30 22:00:51.000000000 -0400
+++ ./memattr.c 2007-10-30 22:23:37.000000000 -0400
@@ -344,12 +344,12 @@ mem_command (char *args, int from_tty)
tok = strtok (args, " \t");
if (!tok)
error (_("no lo address"));
- lo = parse_and_eval_address (tok);
+ lo = parse_and_eval_address (tok, current_language);
tok = strtok (NULL, " \t");
if (!tok)
error (_("no hi address"));
- hi = parse_and_eval_address (tok);
+ hi = parse_and_eval_address (tok, current_language);
attrib = default_mem_attrib;
while ((tok = strtok (NULL, " \t")) != NULL)
Only in ./mi: .mi-cmd-disas.c.swp
Only in ./mi: .mi-main.c.swp
diff -rup ../../gdb-public.2/gdb/mi/mi-cmd-disas.c ./mi/mi-cmd-disas.c
--- ../../gdb-public.2/gdb/mi/mi-cmd-disas.c 2007-10-30 22:00:52.000000000 -0400
+++ ./mi/mi-cmd-disas.c 2007-10-30 22:23:37.000000000 -0400
@@ -25,6 +25,7 @@
#include "gdb_string.h"
#include "ui-out.h"
#include "disasm.h"
+#include "language.h"
/* The arguments to be passed on the command line and parsed here are:
@@ -108,11 +109,11 @@ mi_cmd_disassemble (char *command, char
num_seen = 1;
break;
case START_OPT:
- low = parse_and_eval_address (optarg);
+ low = parse_and_eval_address (optarg, current_language);
start_seen = 1;
break;
case END_OPT:
- high = parse_and_eval_address (optarg);
+ high = parse_and_eval_address (optarg, current_language);
end_seen = 1;
break;
}
diff -rup ../../gdb-public.2/gdb/mi/mi-main.c ./mi/mi-main.c
--- ../../gdb-public.2/gdb/mi/mi-main.c 2007-10-30 22:00:52.000000000 -0400
+++ ./mi/mi-main.c 2007-10-30 22:23:37.000000000 -0400
@@ -630,7 +630,7 @@ mi_cmd_data_write_register_values (char
LONGEST value;
/* Get the value as a number. */
- value = parse_and_eval_address (argv[i + 1]);
+ value = parse_and_eval_address (argv[i + 1], current_language);
/* Write it down. */
regcache_cooked_write_signed (get_current_regcache (), regnum, value);
@@ -829,7 +829,7 @@ mi_cmd_data_read_memory (char *command,
/* Extract all the arguments. */
/* Start address of the memory dump. */
- addr = parse_and_eval_address (argv[0]) + offset;
+ addr = parse_and_eval_address (argv[0], current_language) + offset;
/* The format character to use when displaying a memory word. See
the ``x'' command. */
word_format = argv[1][0];
@@ -1028,7 +1028,7 @@ mi_cmd_data_write_memory (char *command,
/* Extract all the arguments. */
/* Start address of the memory dump. */
- addr = parse_and_eval_address (argv[0]);
+ addr = parse_and_eval_address (argv[0], current_language);
/* The format character to use when displaying a memory word. See
the ``x'' command. */
word_format = argv[1][0];
@@ -1039,7 +1039,7 @@ mi_cmd_data_write_memory (char *command,
addr += (offset * word_size);
/* Get the value as a number. */
- value = parse_and_eval_address (argv[3]);
+ value = parse_and_eval_address (argv[3], current_language);
/* Get the value into an array. */
buffer = xmalloc (word_size);
old_chain = make_cleanup (xfree, buffer);
diff -rup ../../gdb-public.2/gdb/printcmd.c ./printcmd.c
--- ../../gdb-public.2/gdb/printcmd.c 2007-10-30 22:00:52.000000000 -0400
+++ ./printcmd.c 2007-10-30 22:23:37.000000000 -0400
@@ -990,7 +990,7 @@ sym_info (char *arg, int from_tty)
if (!arg)
error_no_arg (_("address"));
- addr = parse_and_eval_address (arg);
+ addr = parse_and_eval_address (arg, current_language);
ALL_OBJSECTIONS (objfile, osect)
{
/* Only process each object file once, even if there's a separate
diff -rup ../../gdb-public.2/gdb/symfile-mem.c ./symfile-mem.c
--- ../../gdb-public.2/gdb/symfile-mem.c 2007-10-30 22:00:52.000000000 -0400
+++ ./symfile-mem.c 2007-10-30 22:23:37.000000000 -0400
@@ -54,6 +54,7 @@
#include "observer.h"
#include "auxv.h"
#include "elf/common.h"
+#include "language.h"
/* Read inferior memory at ADDR to find the header of a loaded object file
@@ -126,7 +127,7 @@ add_symbol_file_from_memory_command (cha
if (args == NULL)
error (_("add-symbol-file-from-memory requires an expression argument"));
- addr = parse_and_eval_address (args);
+ addr = parse_and_eval_address (args, current_language);
/* We need some representative bfd to know the target we are looking at. */
if (symfile_objfile != NULL)
diff -rup ../../gdb-public.2/gdb/symfile.c ./symfile.c
--- ../../gdb-public.2/gdb/symfile.c 2007-10-30 22:00:52.000000000 -0400
+++ ./symfile.c 2007-10-30 22:23:37.000000000 -0400
@@ -2241,7 +2241,7 @@ add_symbol_file_command (char *args, int
char *val = sect_opts[i].value;
char *sec = sect_opts[i].name;
- addr = parse_and_eval_address (val);
+ addr = parse_and_eval_address (val, current_language);
/* Here we store the section offsets in the order they were
entered on the command line. */
diff -rup ../../gdb-public.2/gdb/tracepoint.c ./tracepoint.c
--- ../../gdb-public.2/gdb/tracepoint.c 2007-10-30 22:00:51.000000000 -0400
+++ ./tracepoint.c 2007-10-30 22:23:37.000000000 -0400
@@ -2108,7 +2108,7 @@ trace_find_pc_command (char *args, int f
if (args == 0 || *args == 0)
pc = read_pc (); /* default is current pc */
else
- pc = parse_and_eval_address (args);
+ pc = parse_and_eval_address (args, current_language);
sprintf_vma (tmp, pc);
sprintf (target_buf, "QTFrame:pc:%s", tmp);
@@ -2264,12 +2264,12 @@ trace_find_range_command (char *args, in
*tmp++ = '\0'; /* terminate start address */
while (isspace ((int) *tmp))
tmp++;
- start = parse_and_eval_address (args);
- stop = parse_and_eval_address (tmp);
+ start = parse_and_eval_address (args, current_language);
+ stop = parse_and_eval_address (tmp, current_language);
}
else
{ /* no explicit end address? */
- start = parse_and_eval_address (args);
+ start = parse_and_eval_address (args, current_language);
stop = start + 1; /* ??? */
}
@@ -2303,12 +2303,12 @@ trace_find_outside_command (char *args,
*tmp++ = '\0'; /* terminate start address */
while (isspace ((int) *tmp))
tmp++;
- start = parse_and_eval_address (args);
- stop = parse_and_eval_address (tmp);
+ start = parse_and_eval_address (args, current_language);
+ stop = parse_and_eval_address (tmp, current_language);
}
else
{ /* no explicit end address? */
- start = parse_and_eval_address (args);
+ start = parse_and_eval_address (args, current_language);
stop = start + 1; /* ??? */
}
diff -rup ../../gdb-public.2/gdb/value.h ./value.h
--- ../../gdb-public.2/gdb/value.h 2007-10-30 22:00:52.000000000 -0400
+++ ./value.h 2007-10-30 22:23:37.000000000 -0400
@@ -420,7 +420,8 @@ extern struct value *parse_to_comma_and_
extern struct type *parse_and_eval_type (char *p, int length);
-extern CORE_ADDR parse_and_eval_address (char *exp);
+extern CORE_ADDR parse_and_eval_address
+ (char *exp, const struct language_defn *language);
extern CORE_ADDR parse_and_eval_address_1 (char **expptr);
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [RFC] Reducing the use of current_language - some patches
2007-10-31 10:47 [RFC] Reducing the use of current_language - some patches Joel Brobecker
@ 2007-11-04 17:15 ` Ulrich Weigand
2007-11-05 3:50 ` Joel Brobecker
0 siblings, 1 reply; 6+ messages in thread
From: Ulrich Weigand @ 2007-11-04 17:15 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches
Joel Brobecker wrote:
> As I said before, the goal of this exercise is to avoid having to play
> with the current language in order to do parsing operations in a language
> that may not be the current language.
This sounds like a good idea, thanks for taking care of it!
Just one suggestion that occurred to me: parsing operations depend
on further global state than just the current language; in particular
they depend on the "input_radix", and also on the currently active
gdbarch (which e.g. modifies language primitive types).
So I was wondering if we shouldn't add just a "language" parameter
to the parsing routines, but something more general, like a "parse
context" structure. This could encapsulate all that global state,
and would be easily extensible in the future ...
Maybe (if this is a good idea), it could be done after your current
set of patches; on the other hand, as you're touching all those files
anyway, maybe it would be simpler to do it in one go.
What do you think?
Bye,
Ulrich
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFC] Reducing the use of current_language - some patches
2007-11-04 17:15 ` Ulrich Weigand
@ 2007-11-05 3:50 ` Joel Brobecker
2007-11-05 13:19 ` Daniel Jacobowitz
0 siblings, 1 reply; 6+ messages in thread
From: Joel Brobecker @ 2007-11-05 3:50 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: gdb-patches
Hey Ulrich,
> So I was wondering if we shouldn't add just a "language" parameter
> to the parsing routines, but something more general, like a "parse
> context" structure. This could encapsulate all that global state,
> and would be easily extensible in the future ...
Thanks for your feedback. Indeed, I had completely forgotten about
the input radix, and it should indeed be passed. Having a structure
is a really good idea.
On the other hand, I'm not sure we're ready to have the parse context
contain the gdbarch. For instance, the breakpoint structure doesn't
save it, so we don't have access to it when we want to re_set the
breakpoint.
I propose we start with just the language and the input radix for
this task, and then we can think about incorporating the gdbarch.
> Maybe (if this is a good idea), it could be done after your current
> set of patches; on the other hand, as you're touching all those files
> anyway, maybe it would be simpler to do it in one go.
It would actually be simpler for me to do the work in two phases,
since I'm almost done with the first phase. Now, I have to redo
probably most of it. However, I will do it in one go as it will
create less work for the insight guys, as they will need to update
their sources only once.
Thanks again.
--
Joel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFC] Reducing the use of current_language - some patches
2007-11-05 3:50 ` Joel Brobecker
@ 2007-11-05 13:19 ` Daniel Jacobowitz
2007-11-05 15:25 ` Ulrich Weigand
0 siblings, 1 reply; 6+ messages in thread
From: Daniel Jacobowitz @ 2007-11-05 13:19 UTC (permalink / raw)
To: Joel Brobecker; +Cc: Ulrich Weigand, gdb-patches
On Sun, Nov 04, 2007 at 07:50:14PM -0800, Joel Brobecker wrote:
> On the other hand, I'm not sure we're ready to have the parse context
> contain the gdbarch. For instance, the breakpoint structure doesn't
> save it, so we don't have access to it when we want to re_set the
> breakpoint.
I suspect we'd want to re-set with the current gdbarch anyway. The
old one may no longer apply...
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFC] Reducing the use of current_language - some patches
2007-11-05 13:19 ` Daniel Jacobowitz
@ 2007-11-05 15:25 ` Ulrich Weigand
2007-11-05 17:18 ` Joel Brobecker
0 siblings, 1 reply; 6+ messages in thread
From: Ulrich Weigand @ 2007-11-05 15:25 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: Joel Brobecker, gdb-patches
Daniel Jacobowitz wrote:
> On Sun, Nov 04, 2007 at 07:50:14PM -0800, Joel Brobecker wrote:
> > On the other hand, I'm not sure we're ready to have the parse context
> > contain the gdbarch. For instance, the breakpoint structure doesn't
> > save it, so we don't have access to it when we want to re_set the
> > breakpoint.
>
> I suspect we'd want to re-set with the current gdbarch anyway. The
> old one may no longer apply...
On the other hand, once we support multi-architecture debugging in
a single session, we will certainly have to distinguish between
breakpoints set in code with different architectures. That's one
of the hacks in the Cell combined debugger today ...
I'm not completely sure on what the correct solution is, maybe it
can be as simple as checking the gdbarch associated with the
objfile where the breakpoint is set (assuming we will get per-
objfile gdbarchs at some point).
In any case, as long as the changes Joel implements use something
like a "parse context" structure to pass around, it should be
simple to extend that with a gdbarch if and when we want to solve
the multi-arch problem.
For now, it's probably indeed best to leave it out.
Bye,
Ulrich
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFC] Reducing the use of current_language - some patches
2007-11-05 15:25 ` Ulrich Weigand
@ 2007-11-05 17:18 ` Joel Brobecker
0 siblings, 0 replies; 6+ messages in thread
From: Joel Brobecker @ 2007-11-05 17:18 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: Daniel Jacobowitz, gdb-patches
> In any case, as long as the changes Joel implements use something
> like a "parse context" structure to pass around, it should be
> simple to extend that with a gdbarch if and when we want to solve
> the multi-arch problem.
>
> For now, it's probably indeed best to leave it out.
That sounds good to me. I'll try to work on that this week (there is
something else I want to do for Daniel that I have been postponing
for too long).
--
Joel
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-11-05 17:18 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-31 10:47 [RFC] Reducing the use of current_language - some patches Joel Brobecker
2007-11-04 17:15 ` Ulrich Weigand
2007-11-05 3:50 ` Joel Brobecker
2007-11-05 13:19 ` Daniel Jacobowitz
2007-11-05 15:25 ` Ulrich Weigand
2007-11-05 17:18 ` Joel Brobecker
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox