Project Home
Project Home
Trackers
Trackers
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Variables during debug static function: (7 Items)
   
Variables during debug static function  
Hello,

When debuging a static function in the Debug windows the last function was the caller function and the list of variables
 was also the caller variables.

Is this normal ?
Is there a way to have the statics variables ?

Regards,
Christophe Hannoyer
Re: Variables during debug static function  
Christophe Hannoyer wrote:
> Hello,
> 
> When debuging a static function in the Debug windows the last function was the caller function and the list of 
variables was also the caller variables.

Check if you are compiling your application without 
optimizations (-O0). If not, try recompiling it with -O0. 
The problem is common when compiler inlines functions and 
static functions are by default candidates for inlining.


---
Aleksandar
Re: Variables during debug static function  
Yes I already tried without optimization and it's the same.

I tried to remove the "static" for the function and it fact the problem is still here.
Re: Variables during debug static function  
Christophe Hannoyer wrote:
> Yes I already tried without optimization and it's the same.
> 
> I tried to remove the "static" for the function and it fact the problem is still here.

Then it is very odd. Could you give more information or an 
example, screenshot, etc, so maybe I can understand better 
what is going on? I am not sure at this point if this is gdb 
bug or IDE.

Could you do the following: put a breakpoint in your static 
function. When stopped there, what is IDE presenting? Then 
go to gdb view in IDE and type:

(gdb) bt

and see what is frame #0. It should be your static function.



Thanks,

Aleksandar
Re: Variables during debug static function  
Hello,

> Could you do the following: put a breakpoint in your static 
> function. When stopped there, what is IDE presenting? Then 
> go to gdb view in IDE and type:
> 
> (gdb) bt
> 
> and see what is frame #0. It should be your static function.

I set a break point just before calling the "problem" function.
The Debug view and the bt command in gdb view show the same result. The source code view show the good line and the 
Variables views the good variables.

Then I step into.

The only point which is correct now was the source code view pointing to the right line (the first line in the "problem"
 function).

Debug view and dbg bt show the same stack (the same as before entering in the function, then #0 is not the "problem" 
function) and the Variables view show the caller variables.

I will try to create a specific project to reproduce the problem but it's not really easy.

Thank you for the help,
Christophe
Re: Variables during debug static function  
Christophe Hannoyer wrote:
> Hello,
> 
>> Could you do the following: put a breakpoint in your static 
>> function. When stopped there, what is IDE presenting? Then 
>> go to gdb view in IDE and type:
>>
>> (gdb) bt
>>
>> and see what is frame #0. It should be your static function.
> 
> I set a break point just before calling the "problem" function.
> The Debug view and the bt command in gdb view show the same result. The source code view show the good line and the 
Variables views the good variables.
> 
> Then I step into.
> 
> The only point which is correct now was the source code view pointing to the right line (the first line in the "
problem" function).
> 
> Debug view and dbg bt show the same stack (the same as before entering in the function, then #0 is not the "problem" 
function) and the Variables view show the caller variables.
> 
> I will try to create a specific project to reproduce the problem but it's not really easy.
> 


Thank you for clarifying. IDE and GDB show the same. I 
haven't, however, seen such a case, unless inlining is 
involved where source line may seem to jump back and forth 
between caller and inlined function definition, but stack 
frame will look as the one of the caller.

What would be interesting is to do this in your gdb view:

when you are stoped at your breakpoint (as you described 
above) type this in your gdb view:
display/i $pc

Then, instead of stepping using IDE, use gdb view and do:

stepi

multiple times, which will cause gdb to step instruction by 
insruction. Once you enter problem function, observe 
displayed program counter. Does it display PC within the 
caller's or callee range?


Thanks,

Aleksandar





Re: Variables during debug static function  
Hi Aleksandar,

Thank you for your help. With this and after checking everything carefully I found that I was not using the correct 
executable.

For the story, I was running a previous version instead of the last build executable due to changes in project option 
from the IDE removing in the common.mk some part added manually.

Thanks again for your support,

Christophe