Need help in figuring out why gdb gives different value of a variable in callee vs caller context

Gedare Bloom gedare at rtems.org
Sun Aug 16 22:44:15 UTC 2020


This is wrong: https://github.com/richidubey/rtems/blob/c3162134d3fd7d4d46ec01609d81bdb62bc818af/cpukit/score/src/schedulerstrongapa.c#L182

It assumes the Chain_Node is at the start of the struct
Scheduler_strong_APA_Node.

On Sun, Aug 16, 2020 at 11:34 AM Richi Dubey <richidubey at gmail.com> wrote:
>
> Hi,
>
> The gdb trace above refers to this code where the items in all_Nodes chain are checked. The items in the chain are getting inserted here, before which on line 763, the Affinity of the items is set to all the online processors. Why does the gdb show the Affinity of the node as 0 then? How is this possible? Please advise.
>
> On Sun, Aug 16, 2020 at 5:48 PM Richi Dubey <richidubey at gmail.com> wrote:
>>
>> Oh, I printed the variable value too early. Thanks for your help.
>>
>> On Sat, Aug 15, 2020 at 7:24 PM Gedare Bloom <gedare at rtems.org> wrote:
>>>
>>> On Sat, Aug 15, 2020 at 3:15 AM Richi Dubey <richidubey at gmail.com> wrote:
>>> >
>>> > Hi,
>>> >
>>> > With reference to the code (github link), it aims to check if the Affinty of a node is set to 0 by calling the function _Processor_mask_Is_zero.
>>> >
>>> > While debugging with gdb, I can see using 'p' command that the variable is indeed 0 but after the variable gets passed to the function, the value of the variable isn't 0 anymore. Why is this happening?
>>> >
>>> > Gdb trace:
>>> > ----------------------------------------------------------------------
>>> > (gdb)
>>> > 0x00118af4 187         _Processor_mask_Is_set(&node->Affinity, _Per_CPU_Get_index(curr_CPU) ||
>>> > (gdb)
>>> > 0x00118af6 187         _Processor_mask_Is_set(&node->Affinity, _Per_CPU_Get_index(curr_CPU) ||
>>> > (gdb) p &node->Affinity
>>> > $8 = (Processor_mask *) 0x200efc <_Thread_Objects+2172>
>>> address 0x200efc
>>>
>>> > (gdb) p node->Affinity
>>> > $9 = {
>>> >   __bits = {0}
>>> > }
>>> > (gdb) si
>>> > 0x00118af8 187         _Processor_mask_Is_set(&node->Affinity, _Per_CPU_Get_index(curr_CPU) ||
>>> > (gdb)
>>> > 190         _Processor_mask_Is_zero( &node->Affinity ) )
>>> > (gdb)
>>> > 0x00118afc 190         _Processor_mask_Is_zero( &node->Affinity ) )
>>> > (gdb)
>>> > 0x00118afe 190         _Processor_mask_Is_zero( &node->Affinity ) )
>>> > (gdb)
>>> > 0x00118b00 190         _Processor_mask_Is_zero( &node->Affinity ) )
>>> > (gdb)
>>> > _Processor_mask_Is_zero (mask=0x203580 <_Per_CPU_Information>) at /home/richi/quick-start/src/rtems/cpukit/include/rtems/score/processormask.h:75
>>> > 75 {
>>> > (gdb)
>>> > 0x0011726a 75 {
>>> > (gdb)
>>> > 0x0011726c 75 {
>>> > (gdb) p mask
>>> > $10 = (const Processor_mask *) 0x203580 <_Per_CPU_Information>
>>> address 0x203580
>>>
>>> You're not looking at the same memory location
>>>
>>> > (gdb) p *mask
>>> > $11 = {
>>> >   __bits = {2126656}
>>> > }
>>> > ------------------------------------------------------------
>>> >
>>> > Please provide your views on this.
>>> > Thanks,
>>> > Richi,
>>> > _______________________________________________
>>> > devel mailing list
>>> > devel at rtems.org
>>> > http://lists.rtems.org/mailman/listinfo/devel


More information about the devel mailing list