Author Topic: see content of a vector in debugging  (Read 62858 times)

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5229
Re: see content of a vector in debugging
« Reply #15 on: June 09, 2009, 07:46:01 am »
while we are disliking GDB shortcomings.
Does anyone know how alive GDB is ? There are cvs updates, but real info seems to be real sparse or even completely hidden.
Basically, when will there be a next GDB, anyone any ideas ?

Online oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12344
    • Travis build status
Re: see content of a vector in debugging
« Reply #16 on: June 09, 2009, 09:46:04 am »
/Off
Here: http://sources.redhat.com/gdb/schedule/ there should have been a release already :-)

/On

I don't think, gdb is to blame here. The v is not an array, but a class, v._M_start is an array (or I think it is).
I've not tested, but the value in the watch should be v._M_start[0],
this way you are not depending on the operator[] being present.

Edit:
Here is the official info about C++ STL and gdb: http://sourceware.org/gdb/wiki/STLSupport
« Last Edit: June 09, 2009, 09:54:56 am 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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5229
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: see content of a vector in debugging
« Reply #17 on: June 09, 2009, 10:27:15 am »
Thanks, I'm trying to use this way on MinGW.

http://www.yolinux.com/TUTORIALS/GDB-Commands.html#STLDEREF

Not sure how to add "gdbinit", so, still Googling :D

Edit1:
In my cb debug start up, it the command line ( I copied from debug log output)

Code: [Select]
Command-line: D:\MinGW\bin\gdb.exe -nx -fullname  -quiet -args bin/Debug/test_for_cb_forum.exe
Working dir : C:\test\test_for_cb_forum\

Seems there is default "-nx" options. :(

Edit2

I find in the "gdb_driver.cpp", these code "disable the .gdbinit related function".

Code: [Select]
wxString GDB_driver::GetCommandLine(const wxString& debugger, const wxString& debuggee)
{
    wxString cmd;
    cmd << debugger;
    cmd << _T(" -nx");          // don't run .gdbinit
    cmd << _T(" -fullname ");   // report full-path filenames when breaking
    cmd << _T(" -quiet");       // don't display version on startup
    cmd << _T(" -args ") << debuggee;
    return cmd;
}

wxString GDB_driver::GetCommandLine(const wxString& debugger, int pid)
{
    wxString cmd;
    cmd << debugger;
    cmd << _T(" -nx");          // don't run .gdbinit
    cmd << _T(" -fullname ");   // report full-path filenames when breaking
    cmd << _T(" -quiet");       // don't display version on startup
    cmd << _T(" -pid=") << wxString::Format(_T("%d"), pid);
    return cmd;
}
« Last Edit: June 09, 2009, 10:50:57 am by ollydbg »
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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5229
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: see content of a vector in debugging
« Reply #18 on: June 09, 2009, 12:53:15 pm »
Hi, all, I can successfully view the vectors.

Here is the debug log output from "debugger (debug)" panel.
Code: [Select]
>>>>>>cb_gdb:
> pvector v
elem[0]: $1 = {
  static npos = 4294967295,
  _M_dataplus = {
    <std::allocator<char>> = {
      <__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>},
    members of std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Alloc_hider:
    _M_p = 0x3247c "bla bla"
  }
}
elem[1]: $2 = {
  static npos = 4294967295,
  _M_dataplus = {
    <std::allocator<char>> = {
      <__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>},
    members of std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Alloc_hider:
    _M_p = 0x324ac "abcdef"
  }
}
Vector size = 2
Vector capacity = 2
Element type = std::basic_string<char, std::char_traits<char>, std::allocator<char> > *



There are several steps:

1. copy the "stl-views-1.0.3.gdb" file  to the project directory.( This directory serves as working directory as GDB.exe starts)

2. In the Menu->setting->compiler and debuggers dialog.

Add "source stl-views-1.0.3.gdb" to the debugger initialization command control.

3. start debugging!

4.In the Menu->debug->set user command to the debug dialog.
Enter " pvector v"

5, the v will be shown :D


By the way, I think the "set user command to the debug" dialog should be embeded in the "debugger(debug" panel, so, people don't need to open it again and again. (seems to annoying).

« Last Edit: June 09, 2009, 12:54:49 pm by ollydbg »
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.

Online oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12344
    • Travis build status
Re: see content of a vector in debugging
« Reply #19 on: June 09, 2009, 01:45:09 pm »
Yes, as discussed in the other thread.
I'll see if I can add it there tonight.

If you have more power and desire to hack the vector issue, can you try to use the pvector command in a debugger script (http://wiki.codeblocks.org/index.php?title=Debugger_scripts)?
(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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5229
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: see content of a vector in debugging
« Reply #20 on: June 09, 2009, 04:03:17 pm »
Yes, as discussed in the other thread.
I'll see if I can add it there tonight.

If you have more power and desire to hack the vector issue, can you try to use the pvector command in a debugger script (http://wiki.codeblocks.org/index.php?title=Debugger_scripts)?
Other thread? which thread?

For me, I think writeing a debugger_scripts is beyond my level. :D
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.

Online oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12344
    • Travis build status
Re: see content of a vector in debugging
« Reply #21 on: June 09, 2009, 04:49:24 pm »
Other thread? which thread?

I was talking about this:

By the way, I think the "set user command to the debug" dialog should be embeded in the "debugger(debug" panel, so, people don't need to open it again and again. (seems to annoying).

For me, I think writeing a debugger_scripts is beyond my level. :D
Yes writing a debugger_script looks tough... have not tried it, just read the docs, thought.
(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 jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7253
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: see content of a vector in debugging
« Reply #22 on: June 09, 2009, 06:51:30 pm »

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5229
Re: see content of a vector in debugging
« Reply #23 on: June 09, 2009, 08:41:48 pm »
guys, keep up the good work, I see an interesting patch being created.
This would really enhance the debugging experience in CB !!!

Online oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12344
    • Travis build status
Re: see content of a vector in debugging
« Reply #24 on: June 09, 2009, 11:59:36 pm »
Here is the patch: http://forums.codeblocks.org/index.php/topic,10676.0.html

p.s. Sorry that I'm posting the same thing to multiple threads...
(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 taram

  • Multiple posting newcomer
  • *
  • Posts: 10
  • PhD = permanent head damage :)
Re: see content of a vector in debugging
« Reply #25 on: June 10, 2009, 07:18:30 am »
Quote
guys, keep up the good work, I see an interesting patch being created.
This would really enhance the debugging experience in CB !!!

Quote
Here is the patch: http://forums.codeblocks.org/index.php/topic,10676.0.html

p.s. Sorry that I'm posting the same thing to multiple threads...

Since I am a newbe to CB I am a little bit confused about the "debugger_script" thing and the "patch".

Do we have to install the patch manually or will it be implemented in one of the next nightly builds?

Or do I have to do this:


There are several steps:

1. copy the "stl-views-1.0.3.gdb" file  to the project directory.( This directory serves as working directory as GDB.exe starts)

2. In the Menu->setting->compiler and debuggers dialog.

Add "source stl-views-1.0.3.gdb" to the debugger initialization command control.

3. start debugging!

4.In the Menu->debug->set user command to the debug dialog.
Enter " pvector v"

5, the v will be shown :D


Sorry for this stupid question, but I am still learning.

Thanks

Taram
« Last Edit: June 10, 2009, 07:24:56 am by taram »
O tempora o mores! - Edite, bibite, collegiales, post multa saecula, pocula nulla!

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5229
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: see content of a vector in debugging
« Reply #26 on: June 10, 2009, 07:23:55 am »
Quote
guys, keep up the good work, I see an interesting patch being created.
This would really enhance the debugging experience in CB !!!

Quote
Here is the patch: http://forums.codeblocks.org/index.php/topic,10676.0.html

p.s. Sorry that I'm posting the same thing to multiple threads...

Since I am a newbe to CB I am a little bit confused about the script thing and the patch.

Do we have to install the patch manually or will it be implemented in one of the next nightly builds?

Sorry for this stupid question, but I am still learning.

Thanks

Taram
Well, you need to build the whole CB yourself. See

 http://wiki.codeblocks.org/index.php?title=Installing_Code::Blocks_from_source_on_Windows

For other platforms, you can find similar wiki pages there. :D

For me, I just download the patch, then applied the path to my local source code of CB, then rebuild the CB.

It's not difficult.
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 taram

  • Multiple posting newcomer
  • *
  • Posts: 10
  • PhD = permanent head damage :)
Re: see content of a vector in debugging
« Reply #27 on: June 10, 2009, 07:30:57 am »
Thx for your quick answer ollydbg. I do not use windows.

I am using Debian/Linux and Jens' unofficial debian-repository for Code::Blocks
http://apt.jenslody.de/

So will issue be implemented in a future SVN?  

I have Code::Blocks SVN 5616 right now.

This can then be updated easily by

#apt-get update
#apt-get upgrade

since I am using Jens' debian-repository for Code::Blocks.

Thanks

Taram
« Last Edit: June 10, 2009, 07:36:31 am by taram »
O tempora o mores! - Edite, bibite, collegiales, post multa saecula, pocula nulla!

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5229
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: see content of a vector in debugging
« Reply #28 on: June 10, 2009, 07:39:52 am »
Any developer has the rights to add patch in the trunk(SVN repository).

So, if some dev was interested in this patch, and surely it will be add to trunk. :D
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 killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5229
Re: see content of a vector in debugging
« Reply #29 on: June 10, 2009, 10:30:55 am »
hehe, and the patch I was talking about and hoping to see, is that CB can/will display vectors without having the user to explicitly send a debug command to gdb, and preferably those scripts being active on the global level, and per project ;-)