Author Topic: How to access array elements during debugging C++?  (Read 6308 times)

Offline a6146319

  • Single posting newcomer
  • *
  • Posts: 5
How to access array elements during debugging C++?
« on: August 18, 2014, 12:38:52 pm »
Hello, I am new to Code::Blocks and have a question in debugging. How I can access array elements during debugging? Things get worse if I cannot access array or matrix elements while using a numerical library, such as eigen. If I create watch, it doesn't show contents or array or matrix.  I read this http://wiki.codeblocks.org/index.php?title=Debugging_with_Code::Blocks#Script_support link on debugging with Code::Blocks, but couldn't find what I needed. Any help or comments are very welcome.
BTW, I am using GNU GCC compiler, Code::Blocks 13.12 on Windows.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13438
    • Travis build status
Re: How to access array elements during debugging C++?
« Reply #1 on: August 18, 2014, 08:03:06 pm »
1. Right click -> Properties
2. Enable Treat as array
3. Specify start and count
4. Press Ok and you should be able to see your array
(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!]

Offline a6146319

  • Single posting newcomer
  • *
  • Posts: 5
Re: How to access array elements during debugging C++?
« Reply #2 on: August 19, 2014, 12:27:15 am »
Thanks for your reply. What about if I am using a numerical library such as eigen? Your method does not work there. Is there any different way by which I can extract elements of an array or matrix using eigen (or other) library?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13438
    • Travis build status
Re: How to access array elements during debugging C++?
« Reply #3 on: August 19, 2014, 01:28:59 am »
It depends on the library. If you're using new enough GDB you can probably write a python pretty printers for the data structures of your library.
(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!]