News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

Value in watches not show up for array of char and char* variable

Started by kentut, May 22, 2014, 05:56:02 AM

Previous topic - Next topic

kentut

Hello guys, I am a new codeblocks user, and I really need it for debugging my program consisting of many functions. However, the watches windows can't show up the value of my array of char variable and char* variable. Anyone knows what's wrong with my codeblocks? I have attached the screenshot here.

Thanks guys :)

kentut

Here's screenshot of watches and my variable declaration..

ollydbg

I don't see any thing wrong. The local variable is not initialized, so random values are shown.
What is the expect value shown in the watch window?
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

kentut

Actually the previous screenshot is a called function, variable a and b are parameters passed from the main program, but I can't find the values.
Here's the screenshot in the main program. Although I have initialized b[0] and b[1], it doesn't show the value in watches.

scarphin

Initialize b[0], b[1] to 0x30, 0x31 and try again please.

kentut

Here the screenshot after I set b[0] to 0x30 and b[1] to 0x31. The value still strange....

scarphin

Actually there is nothing strange with the values. 0x30 is '0' and 0x31 is '1' and the first 2 characters of 'b' array correctly shows these values. The rest are some uninitialized random values which may not correspond to printable characters in ASCII table even when initialized to some value. So there doesn't seem to be anything wrong with the CB part.

oBFusCATed

char [] is the same as const char *, so gdb thinks it is a string and tries to print it as string. For function args and locals nothing could be done.
But if you want to inspect the variable as character array, then add it as a watch and right click -> properties -> treat as array (set start and count) and you're good to go.
(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!]