Author Topic: Debug an Array  (Read 27291 times)

Offline hqt

  • Multiple posting newcomer
  • *
  • Posts: 16
Debug an Array
« on: August 09, 2011, 07:04:05 pm »
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:
Code
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:
Code
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 :)

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Debug an Array
« Reply #1 on: August 09, 2011, 10:32:37 pm »
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

  • Guest
Re: Debug an Array
« Reply #2 on: August 09, 2011, 10:58:41 pm »
> 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. 
« Last Edit: August 09, 2011, 11:03:32 pm by Neil Butterworth »

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Debug an Array
« Reply #3 on: August 10, 2011, 04:28:34 am »
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.

Offline hqt

  • Multiple posting newcomer
  • *
  • Posts: 16
Re: Debug an Array
« Reply #4 on: August 10, 2011, 05:01:12 am »
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:)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Debug an Array
« Reply #5 on: August 10, 2011, 05:11:36 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.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.

Offline hqt

  • Multiple posting newcomer
  • *
  • Posts: 16
Re: Debug an Array
« Reply #6 on: August 10, 2011, 05:55:49 am »
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) ?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Debug an Array
« Reply #7 on: August 10, 2011, 06:47:30 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: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Raisolution

  • Guest
Re: Debug an Array
« Reply #8 on: August 05, 2012, 01:18:05 am »
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!

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Debug an Array
« Reply #9 on: August 05, 2012, 08:11:33 pm »
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

  • Guest
Re: Debug an Array
« Reply #10 on: August 10, 2012, 10:36:50 am »
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 :-)

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Debug an Array
« Reply #11 on: August 10, 2012, 10:52:48 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!]