Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] parse and eval breakpoint conditions with correct language
@ 2003-09-10  1:54 Joel Brobecker
  2003-09-10 17:31 ` Jim Blandy
  0 siblings, 1 reply; 13+ messages in thread
From: Joel Brobecker @ 2003-09-10  1:54 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 582 bytes --]

This RFA is a followup on the thread started on gdb@:

    http://sources.redhat.com/ml/gdb/2003-09/msg00082.html

I incorporated Jim's comments (set expout->language_defn, handle
NULL expression_context_block). There was also another gotcha
that the testsuite detected which is to handle the cases when
the context block language is not null, but the unknown language.

2003-09-09  J. Brobecker  <brobecker@gnat.com>

        * parse.c (parse_exp_1): Use the language associated to
        the context block when parsing an expression.

Tested on x86-linux.

Ok to apply?
-- 
Joel

[-- Attachment #2: parse.c.diff --]
[-- Type: text/plain, Size: 1670 bytes --]

Index: parse.c
===================================================================
RCS file: /cvs/src/src/gdb/parse.c,v
retrieving revision 1.36
diff -u -p -r1.36 parse.c
--- parse.c	9 Sep 2003 08:05:42 -0000	1.36
+++ parse.c	10 Sep 2003 01:51:40 -0000
@@ -1107,6 +1107,7 @@ struct expression *
 parse_exp_1 (char **stringptr, struct block *block, int comma)
 {
   struct cleanup *old_chain;
+  const struct language_defn *lang = NULL;
 
   lexptr = *stringptr;
   prev_lexptr = NULL;
@@ -1130,16 +1131,29 @@ parse_exp_1 (char **stringptr, struct bl
   else
     expression_context_block = get_selected_block (&expression_context_pc);
 
+  if (language_mode == language_mode_auto && expression_context_block != NULL)
+    {
+      /* Find the language associated to the context block.
+         Default to the current language if it can not be determined.  */
+      const struct symbol *func = block_function (expression_context_block);
+      if (func != NULL)
+        lang = language_def (SYMBOL_LANGUAGE (func));
+      if (lang == NULL || lang->la_language == language_unknown)
+        lang = current_language;
+    }
+  else
+    lang = current_language;
+
   namecopy = (char *) alloca (strlen (lexptr) + 1);
   expout_size = 10;
   expout_ptr = 0;
   expout = (struct expression *)
     xmalloc (sizeof (struct expression) + EXP_ELEM_TO_BYTES (expout_size));
-  expout->language_defn = current_language;
+  expout->language_defn = lang;
   make_cleanup (free_current_contents, &expout);
 
-  if (current_language->la_parser ())
-    current_language->la_error (NULL);
+  if (lang->la_parser ())
+    lang->la_error (NULL);
 
   discard_cleanups (old_chain);
 

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2003-09-15 19:00 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-10  1:54 [RFA] parse and eval breakpoint conditions with correct language Joel Brobecker
2003-09-10 17:31 ` Jim Blandy
2003-09-11 18:09   ` Joel Brobecker
2003-09-11 18:42     ` Paul Koning
2003-09-11 19:30       ` Joel Brobecker
2003-09-12  1:33         ` Andrew Cagney
2003-09-12  5:46           ` Joel Brobecker
2003-09-15  3:09             ` Jim Blandy
2003-09-15 19:00               ` Joel Brobecker
2003-09-11 19:20     ` Andrew Cagney
2003-09-11 19:32       ` Joel Brobecker
2003-09-11 19:54       ` Daniel Jacobowitz
2003-09-11 22:20     ` Jim Blandy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox