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

Richi Dubey richidubey at gmail.com
Sun Aug 16 12:18:51 UTC 2020


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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20200816/3caef696/attachment.html>


More information about the devel mailing list