From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13128 invoked by alias); 5 Sep 2003 23:28:42 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 13113 invoked from network); 5 Sep 2003 23:28:41 -0000 Received: from unknown (HELO takamaka.act-europe.fr) (142.179.108.108) by sources.redhat.com with SMTP; 5 Sep 2003 23:28:41 -0000 Received: by takamaka.act-europe.fr (Postfix, from userid 507) id 81521D2DAF; Fri, 5 Sep 2003 16:28:39 -0700 (PDT) Date: Fri, 05 Sep 2003 23:28:00 -0000 From: Joel Brobecker To: gdb@sources.redhat.com Subject: Re: Which language when parsing a breakpoint condition? Message-ID: <20030905232839.GC925@gnat.com> References: <20030905232358.GB925@gnat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030905232358.GB925@gnat.com> User-Agent: Mutt/1.4i X-SW-Source: 2003-09/txt/msg00082.txt.bz2 [ARGH! Sorry, my first mail was not finished when I sent it. I wanted to postpone it, and accidentally sent it instead. Here is the message I meant to send.] A friend of mine just asked this question: When you have a multilanguage application (say Ada and C), if the current language is auto,c and you place a conditional breakpoint inside Ada code, which language should be used to parse and evaluate the condition? Ada or C. Intuitevely, I would have say: the Ada parser, since we will be in an Ada function when the breakpoint exception is evaluated. However, GDB currently uses the parser of the language that is current at the time when the user sets the condition (either with the "if" keyword of the "break" command, or when using the "condition" command). So GDB currently uses the C parser. Shouldn't it be the opposite? Looking at the code, I think it is fairly easy to change the behavior to be: 1. If the language is auto, then: a. Determine the language associated to the code where the breakpoint is set, and use it to parse and evaluate the condition b. If unable to determine the language, then use the current language. 2. If the language mode is not auto, then: use the current language. We should be covering all cases by making changing the following line in parse_exp_1... if (current_language->la_parser ()) ... by something like this: struct language_defn *lang = NULL; if (language_mode == language_auto) { /* Find the language associated to the context block. Default to the current language if it can not be determined. */ struct symbol *func = block_function (expression_context_block); if (func != NULL) lang = language_def (SYMBOL_LANGUAGE (func)); if (lang == NULL) lang = current_language; } else { /* Use the current language to parse the string. */ lang = current_language; } /* Parse the string. */ if (lang->la_parser ()) Sounds reasonable? -- Joel