User forums > Using Code::Blocks
Debugging - Watching the contents of fixed size arrays
(1/1)
Léa Massiot:
Hello,
My problem is about debugging within "C::B", "watches" and viewing the contents of fixed size arrays passed to functions.
Below is a simplified example code.
--- Code: ---#define N_ARRAY_S_LENGTH 100
int main()
{
fun_1();
return 0;
}
void fun_1()
{
unsigned char array[N_ARRAY_S_LENGTH];
[...]
fun_2(array);
[...]
}
void fun_2(unsigned char array[N_ARRAY_S_LENGTH])
{
[...]
fun_3(array);
[...]
}
void fun_3(unsigned char array[N_ARRAY_S_LENGTH])
{
array[0] = 'a';
array[1] = 0x0;
array[2] = 'b';
}
--- End code ---
If I watch "array" in the "Watches" view when the debugging cursor points:
- inside "fun_3()" - I get: a
- inside "fun_2()" - I get: a
- inside "fun_1()" - I get: a\000b (this is what I would expect in the two previous cases).
The problem is that I can't check the contents of "array" when I'm inside "fun_3()" or "fun_2()", I have to wait till I'm back into "fun_1()".
So I am wondering why is it behaving that way.
Can you help?
Thank you.
--
OS: Debian GNU/Linux 6.0.3 (squeeze)
C::B SVN 7790
Compiler: GNU GCC Compiler
Debugger: GNU GDB
jarod42:
--- Code: ---void bar(int a[N])
--- End code ---
is equivalent to
--- Code: ---void bar(int a[])
--- End code ---
What you may want is
--- Code: ---void bar(int (&a)[N])
--- End code ---
oBFusCATed:
--- Quote from: Léa Massiot on October 28, 2012, 01:49:42 pm ---The problem is that I can't check the contents of "array" when I'm inside "fun_3()" or "fun_2()", I have to wait till I'm back into "fun_1()".
--- End quote ---
In watches windows do the following:
1. right click on a
2. select properties
3. the check watch as array
4. set the size
5. press ok
Léa Massiot:
Hello jarod42 and oBFusCATed,
Both your solutions work for me.
So, thank you very much for your help :).
Best regards.
Navigation
[0] Message Index
Go to full version