I am doing debugging and wanted to check the place where the value of the variable changes .For this I tried setting a watch point by saying something like watch 'structure->somefunc.getvalue()' which is not a simple variable (probably some portion of a bigger structure invoking a function ) .When I do this gdb says No symbol 'structure->somefunc..' in current context .When I do a grep in the same directory I get 3-4 instances of the same expression.Am I missing out something?
Am I missing out something?
Yes, you appear to be missing at least a couple of things:
The expression structure->somefunc.getvalue()
doesn't make any
sense. You probably meant some_variable->some_field.getvalue()
For that expression to be valid, you must be in a context where some_variable
exists. The fact that some_variable
shows up in grep
output doesn't mean GDB can currently evaluate it. It may be able to evaluate it when you stop the program in correct context.
It makes no sense (and is impossible) to set a watchpoint on return value of getvalue()
. Watchpoints only make sense if you can specify memory location that you want to watch. If (as is likely) getvalue()
returns something like this->m_value
, then what you really want is to set a watchpoint on *(&some_variable->some_field.m_value)
.