Author Topic: std::vector in the debugger: i don't understand the previous topic  (Read 13703 times)

Offline 21did21

  • Multiple posting newcomer
  • *
  • Posts: 20
Hello world,

i am new in programmation (and in code::block); when i debugg, i want to see the contents of the vectors.
I have seen that in this forum there is already one subject ( http://forums.codeblocks.org/index.php/topic,10667.msg73032.html#msg73032 )
but i don't understand it, because:
- my english is poor and in this subject the number of developpement are very long and i don't understand that is important.

Can you resume please for me the different step to can see the content of vector<double> , vector<int>, vector<string> ...
thanks a lot!

ps: in debugg mode, I do not know how to look at the contents of variables: i clikck right on variable and i do :

watch"myVariable"

and in the debugg windows i obtain this: MyVariable=No symbol "myVariable" in current context
« Last Edit: May 03, 2011, 10:48:42 am by 21did21 »

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5345
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: std::vector in the debugger: i don't understand the previous topic
« Reply #1 on: May 03, 2011, 10:49:33 am »
I suggest you can use a python supported gdb.
If you use windows, see:
http://code.google.com/p/qp-gcc/wiki/GDB
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 21did21

  • Multiple posting newcomer
  • *
  • Posts: 20
Re: std::vector in the debugger: i don't understand the previous topic
« Reply #2 on: May 03, 2011, 01:00:16 pm »
I suggest you can use a python supported gdb.
If you use windows, see:
http://code.google.com/p/qp-gcc/wiki/GDB

thank a lot for your help!
i have download the package and i have configurated this step:"Load the python script when Debugger started in Codeblocks" of your page
but after this i always can't see the content of my variables and my vector, other step are necessary?

==> (my english is bad end i am a little beginniner in programmation, this is the reason that it don't understand all)


EDIT:
-for a very simple it's work for double end int type, but it don't work for vector?
-for values close to 0 the debugg show 0 end not 1e-20 !!! it's normal ?
« Last Edit: May 03, 2011, 01:48:59 pm by 21did21 »

Offline 21did21

  • Multiple posting newcomer
  • *
  • Posts: 20
Re: std::vector in the debugger: i don't understand the previous topic
« Reply #3 on: May 03, 2011, 08:22:34 pm »
it's work now!!! thank you a lot !!!

just one think:
==> we can't see the content of:  vector <vector <double>> ?


Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13304
    • Travis build status
Re: std::vector in the debugger: i don't understand the previous topic
« Reply #4 on: May 03, 2011, 08:34:13 pm »
if you use the python pretty printing you can.

To disable the C::B pretty printing you should comment the code inside RegisterTypes in the file gdb_types.script.
(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 21did21

  • Multiple posting newcomer
  • *
  • Posts: 20
Re: std::vector in the debugger: i don't understand the previous topic
« Reply #5 on: May 03, 2011, 09:08:13 pm »
if you use the python pretty printing you can.
To disable the C::B pretty printing you should comment the code inside RegisterTypes in the file gdb_types.script.

sorry I'm not good in what file should I do what you say?
(see attached item)

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13304
    • Travis build status
Re: std::vector in the debugger: i don't understand the previous topic
« Reply #6 on: May 03, 2011, 09:11:50 pm »
Why don't you use the search function of your Explorer?  :lol:
(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 21did21

  • Multiple posting newcomer
  • *
  • Posts: 20
Re: std::vector in the debugger: i don't understand the previous topic
« Reply #7 on: May 03, 2011, 09:39:28 pm »
Why don't you use the search function of your Explorer?  :lol:

 :oops: excuse me I had not thought   :oops:
( it is here:  E:\Program Files\CodeBlocks\share\CodeBlocks\scripts )

But that line i have to modify? i have put in comment all the function " function RegisterTypes(driver) " but my problem is not solve....  :shock:

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13304
    • Travis build status
Re: std::vector in the debugger: i don't understand the previous topic
« Reply #8 on: May 03, 2011, 10:27:26 pm »
Hm, my mistake the python pretty printers are broken, too.

Edit: after more testing it seems to work, partly, but the parser is broken. I'm testing with the debugger's branch. Probably 10.05 is even more broken.
« Last Edit: May 03, 2011, 10:30:17 pm by oBFusCATed »
(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 21did21

  • Multiple posting newcomer
  • *
  • Posts: 20
Re: std::vector in the debugger: i don't understand the previous topic
« Reply #9 on: May 03, 2011, 10:35:37 pm »
Hm, my mistake the python pretty printers are broken, too.
Edit: after more testing it seems to work, partly, but the parser is broken. I'm testing with the debugger's branch. Probably 10.05 is even more broken.

oK? Thank you for your help. if you find the solution please let me informed

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13304
    • Travis build status
Re: std::vector in the debugger: i don't understand the previous topic
« Reply #10 on: May 03, 2011, 11:57:50 pm »
Can you enable the debugger's debug log and paste the output of your debug session?

To enable the log go to Settings -> Compiler & Debugger -> Display debugger's log.

p.s. please use code tags
(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 21did21

  • Multiple posting newcomer
  • *
  • Posts: 20
Re: std::vector in the debugger: i don't understand the previous topic
« Reply #11 on: May 04, 2011, 01:19:53 pm »
Can you enable the debugger's debug log and paste the output of your debug session?
To enable the log go to Settings -> Compiler & Debugger -> Display debugger's log.
p.s. please use code tags

thank you for your help, this is the output of my debugg:
Code
Building to ensure sources are up-to-date
Build succeeded
Selecting target:
Debug
Adding source dir: D:\myProgram\
Adding source dir: D:\myProgram\
Adding file: bin\Debug\myProgram.exe
Starting debugger:
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
Debugger name and version: GNU gdb (GDB) 7.2
Child process PID: 5680
Program exited normally.
Debugger finished with status 0
« Last Edit: May 04, 2011, 01:21:34 pm by 21did21 »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13304
    • Travis build status
Re: std::vector in the debugger: i don't understand the previous topic
« Reply #12 on: May 04, 2011, 01:29:43 pm »
No, it is not.

Code
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Looks like you've not disabled the pretty printers inside C::B!
(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 21did21

  • Multiple posting newcomer
  • *
  • Posts: 20
Re: std::vector in the debugger: i don't understand the previous topic
« Reply #13 on: May 04, 2011, 10:34:18 pm »
No, it is not.
Code
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Looks like you've not disabled the pretty printers inside C::B!

thank you for your help, what is "pretty printers"?
in attached item you have my result (it work for a vector but not for a vector <vector > double > )
and you have my configuration.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13304
    • Travis build status
Re: std::vector in the debugger: i don't understand the previous topic
« Reply #14 on: May 04, 2011, 10:50:44 pm »
Pritty printers are pieces of code which transform the ugly output of gdb in something readable. They hide the implementation details of a vector for example and transform it into something looking like array.

The vector<vector<double>> doesn't work because you have not correctly commented out the function RegisterTypes(driver) function.
(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!]