[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:

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

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

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

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

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):

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:

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:

09.png (28.94 KiB) Viewed 9900 times

That gives now the object and its values:

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

And here just putting "*" in front we access the object itself:
The world is full of love and peace ^_^
User avatar
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 1 guest