The test code both failed in the trunk and debugger branch( with your patch )
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef vector<string> vstr;
int main()
{
vstr v;
v.push_back("bla bla");
string v0 = v[0];
cout << "Hello world!" << endl;
return 0;
}
both v and v0 didn't show correctly in the watch window.
Can you tell me the output of the command "whatis v" at the cout line?
Update:
I've tested it and here is the output
This means that there is no way to make it work.
I'll try to fix the string problem, thought
Update2:
Here is the patch for the string parsing:
Index: src/scripts/gdb_types.script
===================================================================
--- src/scripts/gdb_types.script (revision 5837)
+++ src/scripts/gdb_types.script (working copy)
@@ -24,7 +24,7 @@
// STL String
driver.RegisterType(
_T("STL String"),
- _T("^std::basic_string<.*>$"),
+ _T("(^std::basic_string<.*)|(^string$)|(^const string$)|(^string &$)|(^const string &$)"),
_T("Evaluate_StlString"),
_T("Parse_StlString")
);
@@ -32,7 +32,7 @@
// STL Vector
driver.RegisterType(
_T("STL Vector"),
- _T("^std::vector<(.*)>$"),
+ _T("^std::vector<.*"),
_T("Evaluate_StlVector"),
_T("Parse_StlVector")
);
@@ -109,16 +109,17 @@
function Evaluate_StlString(type, a_str, start, count)
{
+ local v_str = _T("(") + a_str + _T(")");
local oper = _T(".");
if (type.Find(_T("*"), false) > 0)
oper = _T("->");
- local result = _T("output ") + a_str + oper + _T("c_str()[") + start + _T("]@");
+ local result = _T("output ") + v_str + oper + _T("c_str()[") + start + _T("]@");
if (count != 0)
result = result + count;
else
- result = result + a_str + oper + _T("size()");
+ result = result + v_str + oper + _T("size()");
return result;
}
If you find a case where it doesn't work, please report it and provide a simple example.
p.s. patch is in the debugger branch
Update3:
ptype command can help to solve the vector issue, but the output of it is quite big and complete
Using this patch, the variable v still can't be shown correctly. See the screen shot.
Edit:
If I manually enter : pvector v command, the output is ok in the "Debuger(debug)" panel.
> 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 = 0x324dc "bla bla"
}
}
Vector size = 1
Vector capacity = 1
Element type = std::basic_string<char, std::char_traits<char>, std::allocator<char> >
>>>>>>cb_gdb:
[attachment deleted by admin]
Works here (on linux).
Vector declared as:
filled with:
v.push_back(1);
v.push_back(2);
v.push_back(3);
Screenshot of the watches window attached.
EDIT:
too late :(
[attachment deleted by admin]
I'm not sure about trunk, probably no.
In the debugger branch locals and function args are missing at all.
There I want to add multiple watch windows + maybe locals and functions args windows. But I'm not exactly sure how to handle this.
Also we need a way to parse:
struct A
{
int a;
string b;
vector<int> c;
};
But implementing this will make stepping even slower...