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

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: see content of a vector in debugging
« Reply #30 on: June 10, 2009, 10:57:03 am »
You'll see it  :lol:

You're saying that C::B should ship with the stl.gdb script?
And you want to have a checkbox in the options "use stl debugging script"?

One options is to add a list with user/system defined gdb scripts and when we start the debugger we source the chosen 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 Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: see content of a vector in debugging
« Reply #31 on: June 10, 2009, 11:07:04 am »
You'll see it  :lol:

You're saying that C::B should ship with the stl.gdb script?
And you want to have a checkbox in the options "use stl debugging script"?

One options is to add a list with user/system defined gdb scripts and when we start the debugger we source the chosen scripts.

I would prefer to have it similar to the STL-string script, we already have to make STL-strings visible.
Sending commands directly to gdb, if I want to debug a vector and have the output inside gdb's logging window is possible, but not what I would expect.

This should be transparent, and only the values inside the vectors are of interest (normally) and not all the other stuff, we also get when using the script and the pvector command.

I think this should be possible, and I will try it, if I find the time.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: see content of a vector in debugging
« Reply #32 on: June 10, 2009, 12:43:11 pm »
Yes the value of the vector, show be visible in the watch window.
The user would not need to enter the pvector command.

But the script might not be possible without it. I'm not sure, though :(
(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 oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: see content of a vector in debugging
« Reply #33 on: June 10, 2009, 10:34:59 pm »
I'm playing with the debug script for the vector class
And I need some help with the parse function.

Can someone explain what is the format of the string that the Parse_MyClass function should emit?
There are no docs and looking at the source of the parser won't help me match :(


keep your fingers crossed :)
(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 oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: see content of a vector in debugging
« Reply #34 on: June 10, 2009, 11:47:11 pm »
OK, I've achieved 99% success.

0. Apply the script bindings patch (the patch adds the tointeger function)
1. Follow the steps in the ollydbg's post. You need working pvector command
2. Replace the gdb_types.script with the attached one
3. Have fun debugging vectors (see the main.cpp file for a working test case :) )

Known problem: does not work for vector< vector<int> > types.

[attachment deleted by admin]
(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 #35 on: June 11, 2009, 03:38:45 am »
Wonderful Job!!!!

I tested it and it can work on vector<int>.
Thank you very much!!!!!

Here is a screen shot.


By the way, I'm not fully understand what the sentence means. :(
Quote
Can someone explain what is the format of the string that the Parse_MyClass function should emit?
There are no docs and looking at the source of the parser won't help me

Where is the term "Parse_MyClass" function?


Edit:
I can't upload attachment any more, because my upload folder is full. So I have to upload the image to an external site. :(
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 #36 on: June 11, 2009, 08:30:02 am »
Where is the term "Parse_MyClass" function?

This is fictional name, when you write a debug script you need to provide to functions Evaluate_MyClass and Parse_MyClass.

btw: It works on the vector<struct>, too :)

The vector<vector<> > case requires script binding for
Code
local cmd_result = ExecuteDebuggerCmd("pvector $1");
or
local parsed_value = DebuggerEvaluateVariable("$1"); // $1 is a gdb variable I think
This way when I iterate the elements of the vector, I can evaluate and then parse them if they are complex
(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 MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: see content of a vector in debugging
« Reply #37 on: June 11, 2009, 09:13:29 am »
OK, I've achieved 99% success.
Nice work! :-)

Anyways (taking the risk of nut-picking): Please name script bindings with names that really tell what they do. I have renamed the "tointeger" function intol "wxString_ToLong". Because that's what is actually happening. And only that.
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 oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: see content of a vector in debugging
« Reply #38 on: June 11, 2009, 09:35:37 am »
No problem, my idea with the naming was to replicate the build-in tonumber function of squirrel. And I have no problems with the new name (except that it will be good if you sync the wxaui branch to trunk, because that is what I'm using).

What about the other two scripting functions that are required? Are they hard to implement?
The former will be used to implement squirrel version of the stl-views file, at the moment that is not possible.
The latter will be used in parsing of complex structures.

At the moment (I think) if the vector is part of a struct it won't be parsed, when the tree item of the struct is expanded:

Code
struct 
{
    std::string s;
    std::vector<int> v;
} a;

In the watches
a
 |-- s   <--- not parsed as string
 |-- v   <--- not parsed as vector

BTW: the std::list will require two commands to be parsed
1. plist list (to find its T type)
2. plist list T to get the structure
(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 MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: see content of a vector in debugging
« Reply #39 on: June 11, 2009, 11:40:57 am »
No problem, my idea with the naming was to replicate [...]
I have updated the script binding even more. I had started to do it several month ago and had in mind to bind the wxString functions. If you want to, place your ToLong function into the "right" place now. ;-)
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 oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: see content of a vector in debugging
« Reply #40 on: June 11, 2009, 12:15:20 pm »
OK, but what revision is that ... I haven't seen it in the log on the site :(
(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 #41 on: June 11, 2009, 12:25:57 pm »
@Morton

did you already add the apply/commit all those changes to have the vector debug support completely , that is the gdb_types.script ?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: see content of a vector in debugging
« Reply #42 on: June 11, 2009, 01:10:52 pm »
killerbot - my gdb_types.script file is just a test, a demonstration what can be done, it needs polishing  8)
(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 MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: see content of a vector in debugging
« Reply #43 on: June 11, 2009, 01:21:20 pm »
OK, but what revision is that ... I haven't seen it in the log on the site :(
Revision 5630 (trunk)
Revision 5638 (trunk)

did you already add the apply/commit [...] gdb_types.script ?
No. I haven't completely tried myself. So I didn't commit that part.
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 killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5490
Re: see content of a vector in debugging
« Reply #44 on: June 11, 2009, 01:50:01 pm »
killerbot - my gdb_types.script file is just a test, a demonstration what can be done, it needs polishing  8)

When could you have such a polished version. I would test it this weekend, and then commit it if all is ok.