Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: const451 on June 10, 2011, 05:26:26 pm

Title: Local Variables does not show all variables when I step into a function
Post by: const451 on June 10, 2011, 05:26:26 pm
Hi All,

While debugging, Local Variables window does not show all variables when I step into a function. e.g. in the code below it will only show variable "status", that's it, but I want to see s and m_sock.

1) How do I set debugger to show all variables that are in the scope of the function I am stepping into?

2) How can I hover over the variable and see its value?

bool Socket::send ( const std::string s ) const
{
    int status = ::send ( m_sock, s.c_str(), s.size(), MSG_NOSIGNAL );
    if ( status == -1 )
    {
        return false;
    }
    else
    {
        return true;
    }
}


THX!
Title: Re: Local Variables does not show all variables when I step into a function
Post by: oBFusCATed on June 10, 2011, 05:32:07 pm
Hm, you're missing the definition of local variables....

s is a function argument, not a local var
m_sock is member of the class, not a local var again...
Title: Re: Local Variables does not show all variables when I step into a function
Post by: const451 on June 10, 2011, 05:46:41 pm
I am not missing anything, my function is fully legitimate. It's true that those are not local variables, however my questions are:

1) How do I set up Codeblocks to show all variables that are in the scope (not only local variables) of the function I am stepping into?

2) How can I hover over the variable and see its value?

Title: Re: Local Variables does not show all variables when I step into a function
Post by: oBFusCATed on June 10, 2011, 06:09:33 pm
1. You can't, as far as I know, GDB doesn't support such feature.
2. See the debugger settings for the second question. The option is called 'Evaluate expression under cursor'
Title: Re: Local Variables does not show all variables when I step into a function
Post by: ouch on June 10, 2011, 06:19:56 pm
keep in mind you can add any variables to the watch list and see them whether they are in scope or not.
Title: Re: Local Variables does not show all variables when I step into a function
Post by: const451 on June 10, 2011, 07:26:09 pm
1. You can't, as far as I know, GDB doesn't support such feature.
2. See the debugger settings for the second question. The option is called 'Evaluate expression under cursor'



2) Works - Thank you!

Concerning 1): since #2 works - I can hover over any variable, including local, global, and class members and I can see the value while I am inside a function, then such feature is supported by gdb. It's just a matter of Codeblocks having a window to display the values of all those variables.

I think I'll post another thread.