Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Re: [RFA] Fix frame argument printing when using auto language mode
       [not found] ` <CAH=s-PM+9dGs12pLNDZTcr69tdkTMDdyFhAwhHHL037vkvqCKQ@mail.gmail.com>
@ 2018-02-20 16:28   ` Xavier Roirand
  2018-02-20 16:48     ` Yao Qi
  0 siblings, 1 reply; 4+ messages in thread
From: Xavier Roirand @ 2018-02-20 16:28 UTC (permalink / raw)
  To: Yao Qi; +Cc: GDB Patches, Joel Brobecker

Le 2/20/18 à 4:15 PM, Yao Qi a écrit :
> On Mon, Feb 19, 2018 at 12:52 PM, Xavier Roirand <roirand@adacore.com> wrote:
>>
>> The problem is that GDB prints the S parameter in the pck.call_me Ada
>> function using the current language, so the C one, because the program
>> is stopped in a C function, whereas it should use the pck.call_me frame
>> one. This behavior is ok when user manually changes the language but it's
>> not the right one when language is auto.
> 
> Agreed, GDB should use per-frame language instead of global current
> language.  However, instead of switching global variable current_language,
> why don't we pass the per-frame language down to la_val_print?  In
> ada-valprint.c:ada_val_print,
> 
>        ada_val_print_1 (type, embedded_offset, address,
>         stream, recurse, val, options,
>         current_language);
>         ^^^^^^^^^^^^^^^^^
> 
> why don't pass language for ada here?
> 

Hello Yao,

It was my first idea, but it would imply a consequent amount of work 
because when ada_val_print_1 is called, the stack is the following one:

#0  ada_val_print_1
#1  ada_val_print
#2  val_print (got the language of the frame arg)

So if we want to pass the per-frame language down to ada_val_print_1 
then in the generic val_print function, we have to change:

       language->la_val_print (type, embedded_offset, address,
                               stream, recurse, val,
                               &local_opts);
to something like:

       language->la_val_print (type, embedded_offset, address,
                               stream, recurse, val,
                               &local_opts, language);
                                            ^^^^^^^^

Fix me if I'm wrong but it means that <language>_val_print functions for 
all the supported GDB languages have to be modified in order to support 
the language parameter.

Regards.


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

* Re: [RFA] Fix frame argument printing when using auto language mode
  2018-02-20 16:28   ` [RFA] Fix frame argument printing when using auto language mode Xavier Roirand
@ 2018-02-20 16:48     ` Yao Qi
  2018-02-21 16:12       ` Xavier Roirand
  2018-02-22  3:38       ` Joel Brobecker
  0 siblings, 2 replies; 4+ messages in thread
From: Yao Qi @ 2018-02-20 16:48 UTC (permalink / raw)
  To: Xavier Roirand; +Cc: GDB Patches, Joel Brobecker

On Tue, Feb 20, 2018 at 4:28 PM, Xavier Roirand <roirand@adacore.com> wrote:
>
> It was my first idea, but it would imply a consequent amount of work because
> when ada_val_print_1 is called, the stack is the following one:
>
> #0  ada_val_print_1
> #1  ada_val_print
> #2  val_print (got the language of the frame arg)
>
> So if we want to pass the per-frame language down to ada_val_print_1 then in
> the generic val_print function, we have to change:
>
>       language->la_val_print (type, embedded_offset, address,
>                               stream, recurse, val,
>                               &local_opts);
> to something like:
>
>       language->la_val_print (type, embedded_offset, address,
>                               stream, recurse, val,
>                               &local_opts, language);
>                                            ^^^^^^^^
>

We don't have to do that.  ada_val_print_1 is called in ada_val_print,

      ada_val_print_1 (type, embedded_offset, address,
       stream, recurse, val, options,
       current_language);

and ada_val_print is language->la_val_print in effect, so "language"
is ada_language_defn, and we can rewrite the code above like this,

      ada_val_print_1 (type, embedded_offset, address,
       stream, recurse, val, options,
       &ada_language_defn);

This change may break existing behaviour.  Printing for ada (or other
languages) shouldn't depend on current_language, IMO.

> Fix me if I'm wrong but it means that <language>_val_print functions for all
> the supported GDB languages have to be modified in order to support the
> language parameter.
>

-- 
Yao (齐尧)


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

* Re: [RFA] Fix frame argument printing when using auto language mode
  2018-02-20 16:48     ` Yao Qi
@ 2018-02-21 16:12       ` Xavier Roirand
  2018-02-22  3:38       ` Joel Brobecker
  1 sibling, 0 replies; 4+ messages in thread
From: Xavier Roirand @ 2018-02-21 16:12 UTC (permalink / raw)
  To: gdb-patches

Hello,

This is a doable fix, I don't see any issue with it and hope that it 
will not add any side effect. I'll propose an RFA soon. Thx

Regards

Le 2/20/18 à 5:48 PM, Yao Qi a écrit :
> On Tue, Feb 20, 2018 at 4:28 PM, Xavier Roirand <roirand@adacore.com> wrote:
>>
>> It was my first idea, but it would imply a consequent amount of work because
>> when ada_val_print_1 is called, the stack is the following one:
>>
>> #0  ada_val_print_1
>> #1  ada_val_print
>> #2  val_print (got the language of the frame arg)
>>
>> So if we want to pass the per-frame language down to ada_val_print_1 then in
>> the generic val_print function, we have to change:
>>
>>        language->la_val_print (type, embedded_offset, address,
>>                                stream, recurse, val,
>>                                &local_opts);
>> to something like:
>>
>>        language->la_val_print (type, embedded_offset, address,
>>                                stream, recurse, val,
>>                                &local_opts, language);
>>                                             ^^^^^^^^
>>
> 
> We don't have to do that.  ada_val_print_1 is called in ada_val_print,
> 
>        ada_val_print_1 (type, embedded_offset, address,
>         stream, recurse, val, options,
>         current_language);
> 
> and ada_val_print is language->la_val_print in effect, so "language"
> is ada_language_defn, and we can rewrite the code above like this,
> 
>        ada_val_print_1 (type, embedded_offset, address,
>         stream, recurse, val, options,
>         &ada_language_defn);
> 
> This change may break existing behaviour.  Printing for ada (or other
> languages) shouldn't depend on current_language, IMO.
> 
>> Fix me if I'm wrong but it means that <language>_val_print functions for all
>> the supported GDB languages have to be modified in order to support the
>> language parameter.
>>
> 


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

* Re: [RFA] Fix frame argument printing when using auto language mode
  2018-02-20 16:48     ` Yao Qi
  2018-02-21 16:12       ` Xavier Roirand
@ 2018-02-22  3:38       ` Joel Brobecker
  1 sibling, 0 replies; 4+ messages in thread
From: Joel Brobecker @ 2018-02-22  3:38 UTC (permalink / raw)
  To: Yao Qi; +Cc: Xavier Roirand, GDB Patches

Hi Yao,

> We don't have to do that.  ada_val_print_1 is called in ada_val_print,
> 
>       ada_val_print_1 (type, embedded_offset, address,
>        stream, recurse, val, options,
>        current_language);
> 
> and ada_val_print is language->la_val_print in effect, so "language"
> is ada_language_defn, and we can rewrite the code above like this,
> 
>       ada_val_print_1 (type, embedded_offset, address,
>        stream, recurse, val, options,
>        &ada_language_defn);
> 
> This change may break existing behaviour.  Printing for ada (or other
> languages) shouldn't depend on current_language, IMO.

Thanks for the extra pair of eyes, and the pertinent suggestions!
FWIW, I agree with you, your fix is much better.

-- 
Joel


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

end of thread, other threads:[~2018-02-22  3:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1519044767-8741-1-git-send-email-roirand@adacore.com>
     [not found] ` <CAH=s-PM+9dGs12pLNDZTcr69tdkTMDdyFhAwhHHL037vkvqCKQ@mail.gmail.com>
2018-02-20 16:28   ` [RFA] Fix frame argument printing when using auto language mode Xavier Roirand
2018-02-20 16:48     ` Yao Qi
2018-02-21 16:12       ` Xavier Roirand
2018-02-22  3:38       ` Joel Brobecker

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