News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

see content of a vector in debugging

Started by taram, June 07, 2009, 08:02:35 AM

Previous topic - Next topic

killerbot

I found out what my issue of yesterday was, the original CB gdb_types.script was back instead of the patched one  :oops:

Just tested the latest script : everything show fines now, though it still says type is "int*"

ollydbg

Quote from: killerbot on June 17, 2009, 08:06:12 AM
I found out what my issue of yesterday was, the original CB gdb_types.script was back instead of the patched one  :oops:

Just tested the latest script : everything show fines now, though it still says type is "int*"


Did you change
line 94:      whatis $arg0._M_impl._M_start 
to whatis *$arg0._M_impl._M_start 

in stl-views-1.0.3.gdb.

Works fine here in TDM-GCC

By ollydbg at 2009-06-16
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.

killerbot

#107
ok, I thought it was a line in our script :-)

EDIT : confirmed it works

ollydbg

Quote from: killerbot on June 17, 2009, 08:29:14 AM
ok, I thought it was a line in our script :-)
At first, I also thought it was in "gdb_types.script"   :D, but didn't find "Line 94" there. So...
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.

killerbot

alright ..................  THANKS to everyone who helped out in writing, testing , commenting the improvements resulting in the ability to see the contents of a vector :-)

I have committed to svn : revision 5653.


But this is just the start ... ;-)

Much much more to think of : vector of vector, list, map, showing std::string / wxString in all cases (I think now there's a difference between member variable, local variable or program argument but  I forgot why ...)

Once more : good job and cheers to all who helped out.

oBFusCATed

Great, thank you for the time too :)

Next step in my TODO (not a real todo list thought) for the debugger is  to find why it is so slow.
I've some clues and I've found some hot spots (fixed one in a previous post in this thread).
Should I start a new thread or to post here?

p.s. I'll test it myself when it reaches the wxaui branch
(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!]

ollydbg

Hi all.

Seems there is a bug, a function name will be recognized as a vector name. See the screen shot:


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.

oBFusCATed

OK, here is a little patch


Index: src/scripts/gdb_types.script
===================================================================
--- src/scripts/gdb_types.script        (revision 5731)
+++ src/scripts/gdb_types.script        (working copy)
@@ -164,9 +164,12 @@
     local element_type_value = vector_info_str.Mid(capacity_end_pos + 15,
                                                    vector_info_str.length() - capacity_end_pos - 15);

-    local result = _T("[size] = ") + size_value + _T("\n");
-    result += _T("[capacity] = ") + capacity_value + _T("\n");
-    result += _T("[element type] = ") + element_type_value + _T("\n");
+    local result = _T("[size] = ") + size_value + _T(",\n");
+    result += _T("[capacity] = ") + capacity_value + _T(",\n");
+    result += _T("[element type] = ") + element_type_value;
+
+    if(size > 0)
+        result += _T(",\n");

     local value_str = a_str;
     for(local item = 0; item < size; item += 1)
@@ -185,8 +188,12 @@
             local equal_pos = elem_value.Find(_T(" = "));
             if(equal_pos >= 0)
                 elem_value.Remove(0, equal_pos + 3);
+            if(item > 0)
+                result += _T(",");
             result += _T("[") + item + _T("] = ") + elem_value + _T("\n");
         }
+        else
+            break;

         value_str.Remove(0, elem_end);
     }



It does two things:
1. Add , at the end of every item/line, so the output more like the one emitted from GDB (not readly needed in trunk, but in my local patch)
2. Fixes an almost infinite loop if the vector is not initialized.



     std::vector<int> v; // <- if you break here and add v to the watches, C::B freezes, because vector.size is very big number (in my case, but it could be anything)
     v.push_back(1);



Best regards...
(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!]

killerbot

Quotestd::vector<int> v; // <- if you break here and add v to the watches, C::B freezes, because vector.size is very big number (in my case, but it could be anything)

the vector size should be 0, according to the standard, right ?

oBFusCATed

If you break on the next line, yes, the size should be 0...
But on the first line the c-tor have not run and the pvector command calculates the size incorrectly... don't know exactly why... 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!]

mgpensar

Hi,

I cannot even see v[0] in debugger. I keep getting a "kernel event / debug exception message". Please see attached image.

I am using:
Windows Vista (not by my choice)
C::B 8.02
mingw 5.1.4
gdb 5.2.1-1

Any suggestions ?

Thank you in advance for your attention !

Quote from: jens on June 07, 2009, 10:12:13 AM
Quote from: ollydbg on June 07, 2009, 08:45:44 AM
I test your code, found it is even bad in my system(MinGW, WindowsXP), I can't view "v[0]".
See my screenshot

You have to use the []-operator in your program, otherwise it gets not compiled in and therefore cannot be used by gdb.

@taram:
watching the variable as array does not work here.

[attachment deleted by admin]

killerbot

your gdb is way too old. Try to upgrade to for example GDB 6.8

Jenna

Quote from: killerbot on September 03, 2009, 11:06:54 PM
your gdb is way too old. Try to upgrade to for example GDB 6.8

And the changesdiscussed in this thread are in trunk and not in the 8.02 release.
If you need them, you should download a recent nighly build, or you have to wait for the next release.

mgpensar

I will download gdb and trunk and give it a try.
Thank you very much !

Quote from: jens on September 03, 2009, 11:24:23 PM
Quote from: killerbot on September 03, 2009, 11:06:54 PM
your gdb is way too old. Try to upgrade to for example GDB 6.8

And the changesdiscussed in this thread are in trunk and not in the 8.02 release.
If you need them, you should download a recent nighly build, or you have to wait for the next release.

drac

You might find this blog entry interesting. It's about STL Visualisation from one of the KDevelop developers.