This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: FW: [ping] [PATCH] In MI mode -var-create --language not working.


Hi Walfred,

On 06/18/2015 01:53 PM, Tedeschi, Walfred wrote:

> I have looked for potential users of the same fix, could not find though.
> Though I was suspicious about the a routine prepare_re_set_context on the breakpoint file.  However there was no clean-up routine there what made me think that the code was already taking care of language on the right way.

That actually looks like a bug.

grepping for make_cleanup_restore_current_language finds these:

 mi/mi-main.c:2253:      make_cleanup_restore_current_language ();
 parse.c:1214:  inner_chain = make_cleanup_restore_current_language ();
 parse.c:1282:      old_chain = make_cleanup_restore_current_language ();

The parse.c ones may postdate your original patch (not sure), but they
look like could/should use the same treatment.  So I still thing we
should have a set_language_and_mode (or some such) function or maybe
even pass the desired language to make_cleanup_restore_current_language
(maybe rename it) and make that set the language and mode, which then
makes it impossible to forget to force manual mode if you're going
to override it.

> Trying to use --language to create a variable showed that --language was
> not always working.  In some cases GDB understands that the language is automatic
> and cannot parse the language set while executing the command.
> In order to fix this just before executing the command language mode
> should be set to manual.  In this way GDB can parse the expression using
> the language given in the command.

Would you mind clarifying the commit log?  I had to apply
the patch locally to understand why/where/how this could happen.
I suggest:

~~~~~
Trying to use --language to create a variable object does not always
work.  If the language mode is set to automatic, and if there's a
selected frame (that is, the program has been started), GDB's parsing
routines switch to the frame's block's language, with the end result
being the explicit --language is ignored.  See parse_exp_in_context_1's
use of language_mode_auto.

In order to fix this, if --language was specified, force the language
mode to manual before executing the MI command.
~~~


> +   Copyright 2014 Free Software Foundation, Inc.

2014-2015

> +# Copyright 2014 Free Software Foundation, Inc.

Ditto.

> +gdb_exit
> \ No newline at end of file

Please add a newline.


> --- a/gdb/utils.c
> +++ b/gdb/utils.c
> @@ -444,24 +444,36 @@ make_cleanup_free_so (struct so_list *so)
>  
>  /* Helper for make_cleanup_restore_current_language.  */
>  
> +struct saved_language_and_mode
> +{
> +  enum language lang;
> +  enum language_mode mode;
> +};
> +
>  static void
>  do_restore_current_language (void *p)
>  {
> -  enum language saved_lang = (uintptr_t) p;
> +  struct saved_language_and_mode *lang_and_mode = p;  enum language 
> + saved_lang = lang_and_mode->lang;
>  

Something really odd here.  Misplaced line break?

> +  language_mode = lang_and_mode->mode;
>    set_language (saved_lang);
>  }
>  
> -/* Remember the current value of CURRENT_LANGUAGE and make it restored when
> -   the cleanup is run.  */
> +/* Remember the current value of CURRENT_LANGUAGE and
> +   LANGUAGE_MODE restoring them when the cleanup is run.  */
>  
>  struct cleanup *
>  make_cleanup_restore_current_language (void)  {
> -  enum language saved_lang = current_language->la_language;
> +  struct saved_language_and_mode *lang_and_mode
> +    = XNEW (struct saved_language_and_mode);
> +
> +  lang_and_mode->lang = current_language->la_language;  
> + lang_and_mode->mode = language_mode;
>  

Indentation looks odd here.  Should be two spaces in the
mode line too.

> +mi_create_breakpoint "-t $srcfile:$bp_lineno" "add bp"\
> +  "del" "struct_test" ".*$srcfile" $bp_lineno $hex \
> +  "MI-language-fortran insert breakpoint at line $bp_lineno (only bp)"

Please avoid line numbers in test messages, so that the test
messages remain stable when someone tweaks the tests' source code.

Thanks,
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]