News:

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

Main Menu

Debug an Array

Started by hqt, August 09, 2011, 07:04:05 PM

Previous topic - Next topic

hqt

I am trying to use Code::Block, But I still get some problem like when I'm using DevC++. In Watch Windows, I want to see A array. (example: int A[5][5]). but in debug windows, I will appear from top to down:
A[1][1]
A[1][2]
...
A[5][5]
This style is to difficult for me to trace an Double Array. I want to view like Free-Pascal:
A[1][1] A[1][2] A[1][3]...
A[2][1] A[2][2] A[2][3]...
....
A[5][1] A[5][2] A[5][3]...

Who know this problem, please answer to me please :(

thanks for all :)

oBFusCATed

What? ... Computing ... Cannot compute...

Seriously why are you using C/C++, but you want it to behave like Pascal?
(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!]

zabzonk

#2
> Seriously why are you using C/C++, but you want it to behave like Pascal?

I don't think he wants it to behave like Pascal, just to be displayed in a slightly more user-friendly and/or space-saving way. 

ollydbg

Not sure how OP did, but it works OK. (BTW: array index should start from 0, not 1 in C/C++)
see the screen shot 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.

hqt

Oh, It's very nice and very clear to debug. But how can you do that, please tell to me please.
(In your pictures, I seems You run on Redhat/Linux, But I'm using Code::Block on Windows, so I don't know if there are some different points between these version)
thanks:)

ollydbg

Quote from: hqt on August 10, 2011, 05:01:12 AM
In your pictures, I seems You run on Redhat/Linux, But I'm using Code::Block on Windows
I'm using C::B under Windows XP.
Please try a nightly build C::B, such as:
http://forums.next.codeblocks.org/index.php/board,20.0.html
(choose the debugger branch version, which has more debug feature improved)
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.

hqt

Oh, thanks very much :) I can use Code::Block Nightfall and the Debugger is nice :)
But I have an other question: my computer now have two version of Code::Block: first is normal and second is Nightfall version. Can I delete normal version (and this action will not take any damage to other part) ?

MortenMacFly

Quote from: hqt on August 10, 2011, 05:55:49 AM
Can I delete normal version (and this action will not take any damage to other part) ?
Yes. You should (however) also delete the config file "default.conf" in %APPDATA%\codeblocks. This will basically initialise C::B from scratch.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

Raisolution

Hello,
I am a new CB user and recently downloaded the latest CB nightly build, hoping for a better debugger. Actually it's worse. It don't have autos and locals and I don't get the arrays visualized like on the screenshot (it just shows the address). How to configure it to be like the one on the screenshot?

Thanks in advance!

oBFusCATed

For arrays:
1. Right click on the watch -> properties
2. Enable watch as array
3. Set first element and count
(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!]

dalanz

I have the same problem. I want to debug an array, and I'm not able to see it.

I've installed Ubuntu 12.04 LTS, and Code::Blocks 10.05. I tried to use the nightly version, but I can only open the program with Wine (inserted dll files).

How can I see the array when I'm debugging? Besides, a message appears in the console when I start. It says: "warning: GDB: Failed to set controlling terminal: Invalid argument"

P.S: I am a new user with Ubuntu and Code::Blocks :-)

oBFusCATed

Quote from: dalanz on August 10, 2012, 10:36:50 AM
I've installed Ubuntu 12.04 LTS, and Code::Blocks 10.05. I tried to use the nightly version, but I can only open the program with Wine (inserted dll files).
What about reading a few posts (most of the time the second post) below the first post in a nightly topic and then use the proper way to install it on ubuntu?
(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!]