[Codeblocks] debug watches

Welcome in the osRose emulator Project.

Moderators: osRose dev team, ospRose dev team, osiRose dev team, Moderators

[Codeblocks] debug watches

Postby lmame on Tue Feb 16, 2010 11:57 am

Check this thread first for debug basis.



Ok here is a follow up on what are watches.
When you have a crash (or when you debug) watches are useful since with them you can... watch variables values, hence the name.

Basically once it crashes (or you set a breakpoint) the project "freezes" and you can ask the C++ editor what are the values that are at this specific time.

So here it crashed:
01.png


Let's open open the watches window (Debug->Debugging windows->watches), by default there aren't a lot of things:
02.png


so you need to add the variables you want to see, so right click and "add watch":
03.png


Here we want to see the value of the variable "my_value", so let's type "my_value" and click "ok":
04.png


And we got the value of the variable "my_value" (123 here):
05.png


We can do the same for the string "my_string" or the vector "testvector", you see that testvector is listed as an array since it contains several classes here (if you don't know what a vector is, google is your friend):
06.png


Let's access the value that is stored in the position "1" of testvector ("testvector.at(1)"), you see that we have a "weird" thing like *2434242, it's a memory address where the object is:
07.png


If you want to see the object and its values, you need to add a "*" before the testvector.at(1) so "*testvector.at(1)", to select the variable, right click on it and select "edit watch" to add the "*" once again if you don't know what a pointer is, google is your friend:
08.png

09.png
09.png (28.94 KiB) Viewed 9148 times


That gives now the object and its values:
10.png


Here is the same example with a classe T2, here we have the pointer (memory adress):
11.png


And here just putting "*" in front we access the object itself:
12.png
The world is full of love and peace ^_^
Image
User avatar
lmame
Admin
Admin
 
Posts: 8997
Joined: Mon Aug 06, 2007 4:42 pm
Location: July City

Return to Support - OsRose Emulator

Who is online

Users browsing this forum: No registered users and 4 guests

cron