User forums > Using Code::Blocks
No longer viewing wxString objects in the debug watches window
(1/1)
blinkinhek:
I have used Code::Blocks a long time, with wxWidgets, and am currently on v10.05.
I no longer seem to be able to view wxString objects in the debug Watch window (as per attached)
(hope you can see the capture image, I struggled with adding a link to the image)
Sneedd:
Had the same problem for a long time. Today I tried to solve this issue and here is my solution:
The problem actually occurs because wxWidgets (I guess since 2.9.?) is now using std::string internally. If you want more information on this, you could look into wx/stringimpl.h and search for #define wxUSE_STL_BASED_WXSTRING. It is also possible to use their own implementation, if you #define wxUSE_STL_BASED_WXSTRING 0 when building wxWidgets.
Because I do not want to switch back, I looked into the share/CodeBlocks/scripts/gdb_types.script file for another solution. I'm not sure if the following code is 100% correct, but it actually works. Just put the following functions into the script and change in the RegisterTypes function the wxString type to the new functions.
--- Code: ---function RegisterTypes(driver)
{
// wxString
driver.RegisterType(
_T("wxString"),
_T("[^[:alnum:]_]*wxString[^[:alnum:]_]*"),
_T("Evaluate_wxString3std"),
_T("Parse_wxString3std")
);
// ...
}
function Evaluate_wxString3std(type, a_str, start, count)
{
local oper = _T(".");
if (type.Find(_T("*"), false) > 0)
oper = _T("->");
return _T("print ") + a_str + oper + _T("m_impl._M_dataplus._M_p");
}
function Parse_wxString3std(a_str, start)
{
local index = a_str.Find(_T("\""));
if (index < 0) return _T("");
return a_str.Mid(index, a_str.Length()-index);
}
--- End code ---
It works only with watches not with locals or function arguments (currently using Code::Blocks 13.12). So maybe someone has an answer to the following questions:
- Could the script somehow be executed on locals and functions arguments?
- Is it possible to view the raw data or disable the script on a single variable?
oBFusCATed:
--- Quote from: Sneedd on January 16, 2014, 10:40:39 pm ---It works only with watches not with locals or function arguments (currently using Code::Blocks 13.12). So maybe someone has an answer to the following questions:
- Could the script somehow be executed on locals and functions arguments?
- Is it possible to view the raw data or disable the script on a single variable?
--- End quote ---
Generally it is preferable to use python enabled gdb and wx pretty printer scripts. They will work in the locals.
The raw data cannot be viewed at the moment, but I have it in my ToDo, so it will be possible sometime in the future.
Navigation
[0] Message Index
Go to full version