User forums > Help

Watches problem

(1/2) > >>

wever:
I am not sure if this is error in code or I am doing something wrong in code::blocks. I have array

--- Code: --- FILES files[256];

--- End code ---
I am saving values to the files[count].name and files[count].filename and I want to check the values which I have in the array files. But I don't see it in the window. I type *files and I see only the first element files[count] but not the rest of the elements. So what to do to watch it complete? With all 256 elements?


--- Code: ---#include <stdio.h>
#include <stdbool.h>
#include <string.h>
 
typedef struct  {
  char * name;
  char * filename;
} FILES;
FILES files[256];
 
int readFiles(FILES * files)
{
char * nameTmp;
nameTmp = "gaussian";
int count = 0;
files[count].name =  (char*) malloc( sizeof(char)*256 );
files[count].filename =  (char*) malloc( sizeof(char)*256 );
strcpy(files[count].name,nameTmp);

count++;

files[count].name =  (char*) malloc( sizeof(char)*256 );
files[count].filename =  (char*) malloc( sizeof(char)*256 );
strcpy(files[count].name,nameTmp);
 
}
 
int main()
{
   readFiles(files);
return 0;
}

--- End code ---

Also is there any shortcut or hotkey to edit the existing item in Watches? I often want to change from files to *files or something and it is uncomfortable to do it through context menu; it would be much better just to press f2 for rename.

Jenna:
Right-click on the watch, chose properties and select to watch as array, set start-element and count.
For dereferencing you can right-click the watch and chose "Dereference [watchname]".
NO shortcuts available.
F2 would be fine for many plavces where we can rename something, but unfortunately it is also used for switching the "Logs & others" frame on and off, so it's not available for historical reasons (and of course backwards compatibility).

wever:
Sometimes I pressed f2 intuitively when I selected the name of variable and no "window Logs & others" opened. Now it opens, but I think there is some bug. Once it opens, once not. Depending on situation. This is not only problem. I noticed that the auto-update does not work for the old variables which are there in the Watch windows from the previous debug run. So I must update them manually. Maybe F5 could update all the variabes/values in the Watch window similar like we have F5 in browser to update page.

Note, that most of my time (at least 35%) which I spent with using Watches I spent with manipulating/fixing the width of columns.

Yet I did not success to watch the array. I did as you did, but I selected the variable first and clicked on it. Then did what you told.

Here is depicted what I see:

Jenna:
If you watch the variable inside the function, you only see the local variable files, but not the global one.
The local variable is just a pointer, but the global one is an array of 256 FILES structs.
So you get different context-menus inside and outside the function and of course different content of the watch.

oBFusCATed:

--- Quote from: wever on September 09, 2014, 03:51:24 pm ---Maybe F5 could update all the variabes/values in the Watch window similar like we have F5 in browser to update page.

--- End quote ---
Can be done, but I have not had a case where it is needed. (It won't be a f5 or any other shortcut, just a menu item).
Probably it will be useful if you disable many watches and then want to update them at once...


--- Quote from: wever on September 09, 2014, 03:51:24 pm ---Note, that most of my time (at least 35%) which I spent with using Watches I spent with manipulating/fixing the width of columns.

--- End quote ---
This is known bug I cannot reproduce reliably... so it is almost impossible to fix...


--- Quote from: wever on September 09, 2014, 03:51:24 pm ---Yet I did not success to watch the array. I did as you did, but I selected the variable first and clicked on it. Then did what you told.

--- End quote ---
Just do what Jens told you and it should work, at least it has worked for me.
If it still doesn't work, you'll have to enable the full log in the settings of the debugger and then paste it in here (use pastebin like service if it is more than a couple of lines).

Navigation

[0] Message Index

[#] Next page

Go to full version