Author Topic: watch value 'inside' adress when debugging?  (Read 1948 times)

Offline Stauricus

  • Multiple posting newcomer
  • *
  • Posts: 10
watch value 'inside' adress when debugging?
« 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?


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!

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12905
    • Travis build status
Re: watch value 'inside' adress when debugging?
« Reply #1 on: February 21, 2019, 08:38:33 pm »
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!]

Offline Stauricus

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: watch value 'inside' adress when debugging?
« Reply #2 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: [Select]
int main(){
    int i = 10;
    int* n[1] = {&i};

    return 0;
}

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12905
    • Travis build status
Re: watch value 'inside' adress when debugging?
« Reply #3 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.
(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!]

Offline Stauricus

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: watch value 'inside' adress when debugging?
« Reply #4 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:





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!
« Last Edit: February 22, 2019, 01:18:07 pm by Stauricus »

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2850
Re: watch value 'inside' adress when debugging?
« Reply #5 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!)