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

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: see content of a vector in debugging
« Reply #75 on: June 15, 2009, 12:18:51 pm »
The updated version of the gdb_types.script uses tointeger, but the function that should be called is wxString_ToLong (Morten likes that name more and modified my bindings patch)
Sorry for the inconvenience. I didn't think this would cause such trouble... :(
I like wxString_ToLong too 8)
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: 5490
Re: see content of a vector in debugging
« Reply #76 on: June 15, 2009, 12:34:42 pm »
3) copied the "stl-views-1.0.3.gdb" into "share\CodeBlocks"
4) debugger settings : init commands added : "source stl-views-1.0.3.gdb"

Try to use full path or path relative to the project's root

relative to project's root is no options, projects can be any where on the system.

FullPath might work.
@Yiannis : can we use macros there, eg CB install directory, data directory , ...  in the gdb init commands?

source $(CB-SOMETHING)/something-else/stl-views-1.0.3.gdb   ???

EDIT : or the debugger plug-in should try to look for those scripts in the CB data directory

EDIT2 : partially answered my own question (see a next post)
« Last Edit: June 15, 2009, 01:19:10 pm by killerbot »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: see content of a vector in debugging
« Reply #77 on: June 15, 2009, 12:39:14 pm »
Don't worry about, that the source command will be executed by the debugger plugin internally or we can add a list with debugger files to be sourced...
(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: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: see content of a vector in debugging
« Reply #78 on: June 15, 2009, 12:50:58 pm »
I find a small hack.

http://sourceware.org/ml/gdb/2007-06/msg00091.html

We can get the gdb environment variables, then write a templary file.

type "show env" in GDB, it will show one variable :

Code
APPDATA=F:\cb_svn\src\output\AppData

I'm wondering if we can use something like

$(APPDATA)/stl-views-1.0.3.gdb

Since the "source" command can't interpret the $(APPDATA) :(
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: 5490
Re: see content of a vector in debugging
« Reply #79 on: June 15, 2009, 01:09:52 pm »
well there are a few options I think :

1) specify in the source command some $CB macro [$DATAPATH] and have the debugger plugin, run macro replacement before creating debug commands from it
Code
    // pass user init-commands
    wxString init = Manager::Get()->GetConfigManager(_T("debugger"))->Read(_T("init_commands"), wxEmptyString);
    // commands are passed in one go, in case the user defines functions in there
    // or else it would lock up...
    QueueCommand(new DebuggerCmd(this, init));

so this would result into :
Code
    // pass user init-commands
    wxString init = Manager::Get()->GetConfigManager(_T("debugger"))->Read(_T("init_commands"), wxEmptyString);
    Manager::Get()->GetMacrosManager()->ReplaceMacros(init);
    // commands are passed in one go, in case the user defines functions in there
    // or else it would lock up...
    QueueCommand(new DebuggerCmd(this, init));


2) just specify the file to source with no extra path and have the command interpreter check in case the command is 'source' to check for the file in the current working directory, and in case not found there, check in the CB app directory (needs to know where that app/data directory is.

Option 1 seems the most easiest and quickest, but maybe not the most user friendliest.

QUESTION : does anyone see a negative side effect of issuing a macro replacement on those debugger init commands ?
« Last Edit: June 15, 2009, 01:20:08 pm by killerbot »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: see content of a vector in debugging
« Reply #80 on: June 15, 2009, 01:21:28 pm »
Don't worry about, that the source command will be executed by the debugger plugin internally or we can add a list with debugger files to be sourced...
So...I tried again and... failed. Let me put the output here (this is what happens if I hover over "vv" of the sample):
> whatis vv
type = vector<std::vector<int, std::allocator<int> >,std::allocator<std::vector<int, std::allocator<int> > > >
>>>>>>cb_gdb:
> output &vv
(vector<std::vector<int, std::allocator<int> >,std::allocator<std::vector<int, std::allocator<int> > > > *) 0x22ff10>>>>>>cb_gdb:
> pvector vv
elem[0]: $1008 = {
  <_Vector_base<int,std::allocator<int> >> = {
    _M_impl = {
      <allocator<int>> = {
        <new_allocator<int>> = {<No data fields>}, <No data fields>},
      members of _Vector_base<int,std::allocator<int> >::_Vector_impl:
      _M_start = 0x3f4210,
      _M_finish = 0x3f4214,
      _M_end_of_storage = 0x3f4214
    }
  }, <No data fields>}
elem[1]: $1009 = {
  <_Vector_base<int,std::allocator<int> >> = {
    _M_impl = {
      <allocator<int>> = {
        <new_allocator<int>> = {<No data fields>}, <No data fields>},
      members of _Vector_base<int,std::allocator<int> >::_Vector_impl:
      _M_start = 0x3f4230,
      _M_finish = 0x3f4238,
      _M_end_of_storage = 0x3f4238
    }
  }, <No data fields>}
elem[2]: $1010 = {
  <_Vector_base<int,std::allocator<int> >> = {
    _M_impl = {
      <allocator<int>> = {
        <new_allocator<int>> = {<No data fields>}, <No data fields>},
      members of _Vector_base<int,std::allocator<int> >::_Vector_impl:
      _M_start = 0x3f42e8,
      _M_finish = 0x3f42f4,
      _M_end_of_storage = 0x3f42f4
    }
  }, <No data fields>}
Vector size = 3
Vector capacity = 4
Element type = vector<int,std::allocator<int> > *
>>>>>>cb_gdb:
Script exception: SquirrelFunction<> call failed

I did use the script provided here:
http://forums.codeblocks.org/index.php/topic,10667.msg73171.html#msg73171
And setup the bindings correctly, sourced the gdb script correctly, verified pvector is working and really use wxString_ToLong (which is also present - I checked that, too).

I don't exactly get what function call failed though...

Funnily, in the "watches" window I only get the "old" output...?!
« Last Edit: June 15, 2009, 01:26:14 pm by MortenMacFly »
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

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: see content of a vector in debugging
« Reply #81 on: June 15, 2009, 01:29:49 pm »


QUESTION : does anyone see a negative side effect of issuing a macro replacement on those debugger init commands ?

Nice work, I'm testing it now! I'll give a report then.

Edit:
Works quite well! No side effect :D


@oBFusCATed
This is what I get to view "vv".
« Last Edit: June 15, 2009, 01:44:58 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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: see content of a vector in debugging
« Reply #82 on: June 15, 2009, 01:44:46 pm »
Morten: check you script console and show the output here

ollydgb: this is a known bug, I've written about it before and it was decided that we will have the simple version (vector<int>) working first and then we'll extend it.
(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 killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5490
Re: see content of a vector in debugging
« Reply #83 on: June 15, 2009, 02:49:55 pm »
my "Manager::Get()->GetMacrosManager()->ReplaceMacros(init);"/ "source $DATAPATH/stl-views-1.0.3.gdb" addition works.

However the main question remains to the other developers : does anyone expect side effects.
« Last Edit: June 15, 2009, 02:58:21 pm by killerbot »

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: see content of a vector in debugging
« Reply #84 on: June 15, 2009, 04:03:41 pm »
However the main question remains to the other developers : does anyone expect side effects.

It mostly depends on whether gdb init commands may have valid $something commands that should NOT be expanded by C::B...
Be patient!
This bug will be fixed soon...

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: see content of a vector in debugging
« Reply #85 on: June 15, 2009, 04:18:47 pm »
However the main question remains to the other developers : does anyone expect side effects.

It mostly depends on whether gdb init commands may have valid $something commands that should NOT be expanded by C::B...
We can have two edit controls. One for expanded, the other then directly passed to GDB :D
« Last Edit: June 15, 2009, 04:26:55 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.

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5490
Re: see content of a vector in debugging
« Reply #86 on: June 15, 2009, 04:19:41 pm »
However the main question remains to the other developers : does anyone expect side effects.

It mostly depends on whether gdb init commands may have valid $something commands that should NOT be expanded by C::B...
does anyone know of such commands ?
My knowledge of gdb is not that big, so because I don't know any is not good enough for a general conclusion ;-)

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: see content of a vector in debugging
« Reply #87 on: June 15, 2009, 05:06:07 pm »
source command might not support variable expansion at all:

http://sourceware.org/ml/gdb/2006-06/msg00092.html
(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 Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: see content of a vector in debugging
« Reply #88 on: June 15, 2009, 06:31:27 pm »
does anyone know of such commands ?

Quote from gdb documentation:
Quote from: gdb-docu
You can use the string ‘$cdir’ to refer to the compilation directory (if one is
recorded), and ‘$cwd’ to refer to the current working directory. ‘$cwd’ is not
the same as ‘.’—the former tracks the current working directory as it changes
during your gdb session, while the latter is immediately expanded to the current
directory at the time you add an entry to the source path.

There seem to be some more:
Quote from: gdb documentation's index
$  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
$$ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
$_ and info breakpoints . . . . . . . . . . . . . . . . . . . . 40
$_ and info line . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
$_, $__, and value history . . . . . . . . . . . . . . . . . . . . 81
$_, convenience variable . . . . . . . . . . . . . . . . . . . . . . 89
$__, convenience variable . . . . . . . . . . . . . . . . . . . . . 89
$_exitcode, convenience variable . . . . . . . . . . . . . 90
$bpnum, convenience variable . . . . . . . . . . . . . . . . . . 38
$cdir, convenience variable . . . . . . . . . . . . . . . . . . . 71
$cwd, convenience variable . . . . . . . . . . . . . . . . . . . . 71
$tpnum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
$trace_file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
$trace_frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
$trace_func . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
$trace_line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
$tracepoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: see content of a vector in debugging
« Reply #89 on: June 15, 2009, 06:59:27 pm »
Does that apply to the source command? Can you give a link for the excerpt from the gdb docs?

Code
(gdb) source $cwd/test.gdb
$cwd/test.gdb: No such file or directory.
(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!]