News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

watch value 'inside' adress when debugging?

Started by Stauricus, February 21, 2019, 08:01:36 PM

Previous topic - Next topic

Stauricus

hello everybody

is it possible, when debugging, to watch a value pointed by a pointer? i mean, to see what is inside that adress?
in this picture, pi shows 0x7fffffffe714. is it possible to see the value 10 trough pi?


i searched about it, and found some people saying to dereference the pointers. but do they mean dereferencing in the actual code? do i have to make it to all pointer variables that i want to see "inside"?  :o

i hope i was able to explain the issue...  :-\
thanks for the help!

oBFusCATed

Add pi as a watch and right click dereference or just add *pi as a watch.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Stauricus

thanks, it works! but and in this another situation, using arrays, is it also possible? it doesn't seems to work to me, since  no "dereference" option shows up.

int main(){
    int i = 10;
    int* n[1] = {&i};

    return 0;
}

oBFusCATed

For arrays you have to right click on the watch -> properties -> mark it as array and specify a size.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Stauricus

#4
it did not work in the case... no "dereference" option yet.
but if i add **pi as a watch, it shows the value. i didn't knew i could add the variable names manually in the watch window before your answers  :P
thank you!


EDIT: ok, no just one more problem. how to watch multidimensional arrays of pointers?
up to now, i'm like this:





but i'm not able to see the values, just adresses.

thanks again!


EDIT AGAIN:
omg, i feel stupid. i didn't knew i could add things like *p[1][1] and *0x5555555a46b0 to the watch screen. problems solved!
thank you very much!

BlueHazzard

just for reference:
Nearly every valid c/c++ expression can be entered in the watches window, also function calls (but be aware, they may crash your application if called in the wrong context and with it also gdb!)