Author Topic: debuging the code: how add variables and arrays objects to watches window?  (Read 7365 times)

Offline cambalinho

  • Multiple posting newcomer
  • *
  • Posts: 93
the watches window adds, automatic, local variables but not what i need to test. for that i nee do it manually(select the variable and then click on right button for add it to watches window).
until here fine, but see these: i have a class button with a getTop() function member.

Code
vector<button> btnarray;
int WinMain()
{
    //int arraysize=ArraySize(btnarray, button);//geting the array size
    btnarray.resize(8);

    for (int i=0; i<btnarray.size(); i++)
    {
        int b=100 + ((i+1)*50);
        btnarray[i].setTop(b);
        //OutputDebugStr(to_string(btnarray[i].getTop()).c_str());
        btnarray[i].setLeft(0);
        btnarray[i].setText(to_string(i));
        btnarray[i].MouseClick=[i]()
        {
            MessageBox(btnarray[i].getText());
        };
    }
now heres the questions points:
- how can i add the btnarray [ i ].getTop() to watches window and see it's value?
- how can i see the string of OutputDebugStr() on debug mode?
« Last Edit: August 05, 2015, 08:57:30 pm by cambalinho »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
1. Select it and wait for the popup to show up or right click -> add watch
2. This is more of a gdb question, but have you tried to enable the debug output in the settings -> debugger?
(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 cambalinho

  • Multiple posting newcomer
  • *
  • Posts: 93
for that i must, 1st, enter\execute on debug mode. on watches window, on value section, i get 'Not available'. what means? why i can't get it's value? or is because i'm not using on code?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
GDB can execute function, but I'm not sure what are the requirements. Sometimes it just fails.

BTW. I have really hard time understanding what you're talking about, please try harder to explain what you're doing.
(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 cambalinho

  • Multiple posting newcomer
  • *
  • Posts: 93
i'm trying using the watches windows for see the btnarray.getTop() value. and send some messages, for test other values, for watches window

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
You have add a watch for btnarray.getTop() or btnarray and then inspect the raw values.
(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 cambalinho

  • Multiple posting newcomer
  • *
  • Posts: 93
i did. but where is the values i get these string 'not avaiblable' or something like these

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Have you read this: http://wiki.codeblocks.org/index.php?title=Debugging_with_Code::Blocks ?
Does it work with simple local variables?
(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 cambalinho

  • Multiple posting newcomer
  • *
  • Posts: 93
finally i get the point.
i must go to getTop() class member and test the intTop value.
thanks for all

Offline cambalinho

  • Multiple posting newcomer
  • *
  • Posts: 93
another question: i can use OutputDebugString() function, but how can i see it's value\string?
(i'm trying, in hard way, learn more about debuging)

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
It should be in the log of the debugger (probably in the full log, which you have to enable in the debugger settings).
I've told you about this already.

Another option is to define it to something that prints on stdout/stderr:)
(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 cambalinho

  • Multiple posting newcomer
  • *
  • Posts: 93
i use windows api applications. so it's there another way?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Have you checked the log?
The debugger tab in you 'logs and others' window.
(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 cambalinho

  • Multiple posting newcomer
  • *
  • Posts: 93
i'm sorry, the string isn't printed on that tab :(
Code
button btnarray[8];
int WinMain()
{
    int arraysize=ArraySize(btnarray, button);//geting the array size
    //btnarray.resize(8);
    int i=0;
    for (i; i<arraysize; i++)
    {
        int inttop=150 + (i*50);
        btnarray[i].setTop(inttop);
        OutputDebugStr(to_string(btnarray[i].getTop()).c_str());//i belive these string must be printed on debugger tab, right?
        btnarray[i].setLeft(0);
        btnarray[i].setText(to_string(i));
        btnarray[i].MouseClick=[i]()
        {
            MessageBox(btnarray[i].getText());
        };

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Generally this is the place where you should see it.

Have you enabled full log from the debugger?
(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!]