Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: Stauricus on February 21, 2019, 08:01:36 pm

Title: watch value 'inside' adress when debugging?
Post by: Stauricus on February 21, 2019, 08:01:36 pm
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?
(https://i.postimg.cc/VLchGHQs/Captura-de-tela-de-2019-02-21-15-42-04.png) (https://postimg.cc/6TYzTcpF)

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!
Title: Re: watch value 'inside' adress when debugging?
Post by: oBFusCATed on February 21, 2019, 08:38:33 pm
Add pi as a watch and right click dereference or just add *pi as a watch.
Title: Re: watch value 'inside' adress when debugging?
Post by: Stauricus on February 22, 2019, 01:46:15 am
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.

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

    return 0;
}
Title: Re: watch value 'inside' adress when debugging?
Post by: oBFusCATed on February 22, 2019, 08:50:49 am
For arrays you have to right click on the watch -> properties -> mark it as array and specify a size.
Title: Re: watch value 'inside' adress when debugging?
Post by: Stauricus on February 22, 2019, 12:57:05 pm
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:

(https://i.postimg.cc/WtZYMLYB/Captura-de-tela-de-2019-02-22-08-57-38.png) (https://postimg.cc/WtZYMLYB)

(https://i.postimg.cc/ygktqDPx/Captura-de-tela-de-2019-02-22-08-53-50.png) (https://postimg.cc/ygktqDPx)

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!
Title: Re: watch value 'inside' adress when debugging?
Post by: BlueHazzard on February 22, 2019, 02:17:14 pm
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!)