Patch #3146 2011-04-16 12:42

cbuser132

CB debugger Plugin can handle vectors witch were typdefed
Download
3146-CB_debugger_Pl.patch (1.9 KB)
Category
Plugin::FeatureAdd
Status
Rejected
Close date
2011-04-17 14:37
Assigned to
tpetrov
Index: src/plugins/debuggergdb/gdb_commands.h
===================================================================
--- src/plugins/debuggergdb/gdb_commands.h    (Revision 7112)
+++ src/plugins/debuggergdb/gdb_commands.h    (Arbeitskopie)
@@ -784,6 +784,46 @@
 };
 
 /**
+  * Command to get the REAL type of the type
+  * will repeat until a registrated type was fond or the same type is retuned
+  */
+class GdbCmd_FindTypeType : public DebuggerCmd
+{
+        GDBWatch::Pointer m_watch;
+    public:
+        GdbCmd_FindTypeType(DebuggerDriver* driver, GDBWatch::Pointer watch) :
+            DebuggerCmd(driver),
+            m_watch(watch)
+        {
+            wxString type;
+            m_watch->GetType(type);
+            m_Cmd << wxT("whatis ");
+            m_Cmd << type;
+        }
+        void ParseOutput(const wxString& output)
+        {
+            // examples:
+            // type = wxString
+            // type = const wxChar
+            // type = Action *
+            // type = bool
+            wxString m_ParseFunc, type, tmp = output.AfterFirst(_T('='));
+            m_watch->GetType(type);
+
+            m_Cmd = static_cast<GDB_driver*>(m_pDriver)->GetScriptedTypeCommand(type, m_ParseFunc);
+            if( m_Cmd.IsEmpty() && type != tmp )
+            {
+                //type = tmp;
+                m_watch->SetType(tmp);
+                m_pDriver->QueueCommand(new GdbCmd_FindTypeType(m_pDriver, m_watch), DebuggerDriver::High);
+                return;
+            }
+            
+            m_pDriver->QueueCommand(new GdbCmd_Watch(m_pDriver, m_watch), DebuggerDriver::High);
+        }
+};
+
+/**
   * Command to get a watched variable's type.
   */
 class GdbCmd_FindWatchType : public DebuggerCmd
@@ -831,7 +871,7 @@
                 m_watch->SetType(tmp);
                 m_watch->SetValue(wxEmptyString);
             }
-            m_pDriver->QueueCommand(new GdbCmd_Watch(m_pDriver, m_watch), DebuggerDriver::High);
+            m_pDriver->QueueCommand(new GdbCmd_FindTypeType(m_pDriver, m_watch), DebuggerDriver::High);
         }
 };
 
cbuser132 2011-04-16 12:59

patch is for the wxpropgrid_debugger branch

tpetrov 2011-04-17 10:29

Can you explain why this patch is needed?

A test case?

cbuser132 2011-04-17 11:51

A lite example:

typedef std::vector<int> Is;

int main()

{

Is is;

is.push_back(45);

}

Without that patch the debuger-plugin will not show "is" as a vector because it is the type "Is" and the plugin has no registrated type "Is". So the plugin sends "output is" to the debugger but "pvector is" will show it the right way. So the patch will call "whatis Is" to find out that "Is" is a vector. And now the registrated type will be found and the debugger plugin sends "pvector is" instead of "output is".

tpetrov 2011-04-17 12:27

A harder example:

typedef std::vector<int> TypeVector;

typedef TypeVector TypeTypeVector;

TypeTypeVector vector;

vector.push_back(10);

In this case your patch won't work, because "whatis TypeVector" returns TypeTypeVector. So you get a no go for the patch.

Another reason is that you're adding another command needed to update every watch, which will slow the update of al watches.

They are pretty slow already, so we can't add features that slow them even more.

By the way have you tried a python enabled gdb + stl pretty printers (gdb 4.5+ have them by default)?

It works even in this case.

Probably there is no reason to improve this patch any further, because I plan to deprecate the scripted pretty printers inside C::B (at least for gdb).

cbuser132 2011-04-17 13:04

okay you can change status to Rejected